HACKER Q&A
📣 davidajackson

What do you like to use for state management with React?


For those building early stage products, how much or how little do you use Redux, etc.? Have some opinions on this but want to hear from others.


  👤 Chyzwar Accepted Answer ✓
Good: It is stable and relatively well understood by most react developers. Redux toolkit eliminate most of the boilerplate and tooling and ecosystem is great. Make a lot of things super easy to implement.

Bad: Make unit testing harder. It is harder to share connected components. Performance can suffer if you are not careful enough. It is unclear how Redux will work with new APIs like suspense.

After many years using redux, my general advice is to create many small reducers with flat structure. Favor thunks over middlewares. Do not access state directly, use reselect selectors by default. Use hooks over hoc from react-redux.


👤 PaulHoule
For some React apps it is simple to concentrate all of the state in a component very near the top and then pass it all down with props.

For other cases there is MobX.

Redux has some intellectual coherence but, in practice, people struggle with it.

To the extent that your components depend on props as opposed to context, mystery hooks, etc., you can unit test your application, debug it, etc.


👤 crate_barre
I still prop drill and try not to prop drill more than two levels. You just have to think a little harder.