DEV Community

Discussion on: Creating persistent, synchronized global store using React Hooks in TypeScript

Collapse
 
theluk profile image
Lukas Klinzing

I would suggest to not use react context as a global single source of truth store. The reason is simply performance. Out of the box the smallest change in the store will make a basically the full page a rerender unless you do a lot of caching and optimization and memoized selectors etc. If you have two distinct objects like user-settings and theme-settings then put them into two different contexts. There is no way a profile is modifying the preferred color. So why triggered that change then. And if for some reason really a profile would change a preferred color, you can always being two consumers together and react accordingly.