Re:The new wave of React state management
by bernawil on Saturday July 02, 2022 @12:24PM
(#31960328)
hah this is an understatement. For hooks, the React runtime already does a ton of non-standard-js things under the hood. useState gives a method to update and "subscribes" a component to updates on the hook's value. Put that code in a custom hook, export it and you re-invented Redux. In fact, exporting a single big useReducer for all your state gives you something almost identical to old style Redux.
[ Parent
| on HN ]
Re:The new wave of React state management
by acemarke on Saturday July 02, 2022 @12:33PM
(#31960412)
FWIW, there _are_ a number of technical and conceptual differences between Context+`useReducer` and Redux. I wrote an extensive post describing those differences and potential use cases for each:
https://blog.isquaredsoftware.com/2021/01/context-redux-diff...