3 ms·
Please note that "modern Redux" code is very different than what most older tutorials show. We've introduced newer APIs like Redux Toolkit, which is a set of ut
by acemarke 4y ago
Please note that "modern Redux" code is very different than what most older tutorials show. We've introduced newer APIs like Redux Toolkit, which is a set of utilities that simplify the most common Redux tasks, and the React-Redux hooks API, which is generally easier to use than the traditional connect API.
I strongly recommend reading through the "Redux Essentials" tutorial [0] in the Redux docs, which has been specifically designed to show "how to use Redux, the right way" with our recommended practices
The older patterns shown in almost all other tutorials on the internet are still valid, but not how we recommend writing Redux code today.
You should also read through the Redux "Style Guide" docs page, which explains our recommended patterns and best practices. Following those will result in better and more maintainable Redux apps.
Redux isn't the right tool for all use cases, and we don't expect everyone to like Redux :) But writing Redux code today with Redux Toolkit and React-Redux hooks is drastically simpler than the legacy-style patterns were a few years ago, and we routinely get positive feedback from folks who hated Redux before and now love using RTK.
It's also worth noting that there's significant technical differences in how Context + `useReducer` work vs how (React-)Redux works, and that affects what kinds of tasks they're suitable for. I covered those in extensive detail in a post [2].
[0] https://redux.js.org/tutorials/essentials/part-1-overview-concepts https://redux.js.org/tutorials/essentials/part-1-overview-co...
[1] https://redux.js.org/style-guide/ https://redux.js.org/style-guide/
[2] https://blog.isquaredsoftware.com/2021/01/context-redux-differences/ https://blog.isquaredsoftware.com/2021/01/context-redux-diff...
- solardev 4y agoI wasn't aware that your syntax has changed, thanks for the heads-up! I inherited an older codebase and found Redux to be the single most complicated part of a relatively straightforward app, and was turned off by what seemed like needless overengineering for relatively simple use cases. I could see the power behind Redux and ReactJS but it was frankly overkill for what we needed. I will definitely check out your links when I get back to work next week. Thank you for sharing!
- acemarke 4y agoYep, Redux usage has changed _significantly_ in the last few years :) Also see these talks I did on "modern Redux with RTK" and "the evolution of Redux async logic": - https://blog.isquaredsoftware.com/2022/06/presentations-modern-redux-rtk/ https://blog.isquaredsoftware.com/2022/06/presentations-mode... - https://blog.isquaredsoftware.com/2022/05/presentations-evolution-redux-async-logic/ https://blog.isquaredsoftware.com/2022/05/presentations-evol...