DEV Community

Discussion on: The Art of State Management in React.

Collapse
 
eddiecooro profile image
Eddie • Edited

Hey Vorillaz, thanks for this great article. I had some doubts regarding using use-context-selector in the production. now I see you benefit from it, I have more courage to test that in my application.
Also, I think there is a small issue in your Provider; you are using useCallback(() => setState(), []) but the setState function returned from the useState hook is guaranteed to not change at all and memoizing it is not useful at all.
Also, check the react-tracked library. it's from the same author as the use-context-selector and has a nice API alongside all of these performance optimizations out of the box.

Collapse
 
vorillaz profile image
vorillaz

Hey Eddie, thanks a lot for the feedback. Looking forward for the results of your effort and thanks a lot for the suggestions I’ll definitely have a look.