We have to functions right now. createStore
that creates module state and useStore
that consumes the module state that we created.
The logic is working as expected. State is being properly shared to the components that need it while still isolated from the rest of the app. The issue now is that we have extra re-renders in our application. Each component will rerender when any state changes
To fix this, we'll implement a selector function that will peek the value that you need out of state. This way only the components that depend on the value that is changed will re-render.