I recently was building a React app in TypeScript and I felt some friction while I was quickly trying to set up a state management flow. Might not be a problem for everyone, but I was trying to quickly prototype something.
Naturally, I started with Redux, but went on to implement state management in Context. I believe the boilerplate set up for both the approaches is very similar, just the very big plus for me while using Context is that I get to see what exactly is happening, i.e. there is no behind the scenes.
Setting up a useReducer at the root of my app and then providing it with Context is a very simple way to get state management running. Down the tree, you use useContext to pull dispatch and the state. Once this initial setup is done, you can use it normally as Redux.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I recently was building a React app in TypeScript and I felt some friction while I was quickly trying to set up a state management flow. Might not be a problem for everyone, but I was trying to quickly prototype something.
Naturally, I started with Redux, but went on to implement state management in Context. I believe the boilerplate set up for both the approaches is very similar, just the very big plus for me while using Context is that I get to see what exactly is happening, i.e. there is no behind the scenes.
Setting up a useReducer at the root of my app and then providing it with Context is a very simple way to get state management running. Down the tree, you use useContext to pull dispatch and the state. Once this initial setup is done, you can use it normally as Redux.