DEV Community

loading...

Discussion on: Global state management in React with global variables and hooks. State management doesn't have to be so hard.

Collapse
supunkavinda profile image
Supun Kavinda

We use your state-pool in our production system and it works great. We don't have to worry about hard-to-maintain Context API. Thank you very much for the innovative work. Also, I wonder why React doesn't support this approach by default.

Also, I've created a minified version (200 bytes gziped) of state-pool for Preact (github.com/SupunKavinda/preact-glo...), with one hook, useGlobalState.

Btw, I saw that you are using immer as an dependency. Is it for the reducer?

Collapse
yezyilomo profile image
Yezy Ilomo Author

Immer is used for object comparisons to make sure that even a small change in object property triggers re-render to all components subscribed to a related global state.

Forem Open with the Forem app