4 ms·
As mentioned in a sibling comment: We have a new official "Redux Toolkit" package [0], which is now our recommended way to write Redux logic. It includes util
by acemarke 6y ago
As mentioned in a sibling comment:
We have a new official "Redux Toolkit" package [0], which is now our recommended way to write Redux logic. It includes utilities to simplify several common Redux use cases, including store setup, defining reducers, immutable update logic, and even creating entire "slices" of state at once. We've also recently added APIs for basic async data fetching via thunks, and reusable functions for managing normalized entity state.
Meanwhile, we now recommend the React-Redux hooks API [1] as the default way to interact with the Redux store in your components. It provides `useSelector` and `useDispatch` hooks, which are lighter-weight and generally easier to understand and work with than `connect` is. They're also much easier to use with TypeScript.
The Redux docs have always been very unopinionated, and just said "here's 3 different ways to do this task" (such as describing the typical "folder-by-type" / "feature folder" / "ducks" folder structures, but not giving an actual suggestion on which approach to use). We now have a "Style Guide" docs page [2] that gives our actual recommendations on how to use Redux the right way, such as "put more logic in Reducers", "model actions as 'events' instead of 'setters' ", and "use the 'ducks' pattern for single-file logic".
So, while the actual Redux core hasn't changed, the way you'd write your Redux code now would be significantly different than what you might have seen a couple years ago, and the new "Redux Essentials" tutorial linked in this HN thread is intended to teach these latest practices.
[0] https://redux-toolkit.js.org https://redux-toolkit.js.org
[1] https://react-redux.js.org/api/hooks https://react-redux.js.org/api/hooks
[2] https://redux.js.org/style-guide/style-guide https://redux.js.org/style-guide/style-guide