44 likes
·
1.7K reads
4 comments
·Jan 25, 2023
Jan 25, 2023
Nice writeup
1
·
·1 reply
Author
·Jan 25, 2023
Thanks!
·
·Jan 29, 2023
Jan 29, 2023
Nice article but I want to ask whether this way of managing states with both useContext and useReducer scalable?
1
·
·1 reply
Author
·Jan 30, 2023
Hey there, thanks!
Sure, the one I've used in this article is limited to a single complex state, so I use two contexts, one for the state and one for the dispatch function.
But if you plan to keep separate states, and retain the global functionality, you can create each context to deliver the state and the dispatch function in the same provider.
This is similar to how the Redux toolkit does, your slices map out to a state with their own reducer functions, only difference is, you have a common dispatch with the redux toolkit.
1
·