Hey, everyone. Good morning, good afternoon, or good evening. My name is Ebenezer Dawn, advocate at JetBrains for Webster MITE. And I want to talk about efficient state management with hook state.
Okay, what's hook state? Well, it's understandable if you've not heard about hook state before. Hook state is not that old in the game. It's a state management solution for React. And one thing I really like about it, apart from hook state being flexible and it takes simplicity to a whole new level.
So I want to use this application to demo hook states. I know, I know that to do operate is the only way I could show you create read update and delete the simplest way rather than I can show you that with a state management tool like hook state for example. So right in auto job we can complete task that's updating the task. We can also delete that we can add new tasks. So do stuff. And I've decided to use two different components for this application. We have the to dew components which represents the not complete that task, that's one component, we have another component for the completed task. And these two components share the same state, raising hook state for state management.
Now, if we go back to ID right now, I'm in a starter code base, which means I'm not using hook state yet. This we have a starter js file, and then we have tasks inside of it. What if global state management was this easy? What if this is all we needed to do to manage global state, we just have a variable and its name tasks, or whatever state we want. And we export it, then we go back to different components. And all we got to do is import it and use it. Same thing with the not completed component. This is not a fixed state, this is just using JavaScript variables to export and import. You've probably used Redux before, or react context API, or RxJS and all the rest. The state management, it works, it's really efficient, state management with these tools. But it's complex. It's really complex. And I want it to be this easy. I wanted that if I want to add a new task, I have just one method like we have on line 10, like tasks.push. And then I have my new task, instead of using extra slices, reducers, actions and all the rest or the Spread Operator having a previous state and then the next state and all that.
Comments