DEV Community

Discussion on: Setting Up Redux in React

Collapse
 
markerikson profile image
Mark Erikson

Hi, I'm a Redux maintainer. The patterns shown in this post are actually very outdated and we recommend against doing things this way. in 2021, no one should be writing nested spread operations for immutable updates or having to add the thunk middleware to the store separately, and while connect still works fine, we suggest that you not use it.

"Modern Redux" code is very different than what most older tutorials show. We've introduced newer APIs like our official Redux Toolkit package , which is a set of utilities that provide a light abstraction to 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 newly rewritten official tutorials in the Redux docs, which have been specifically designed to teach you how Redux works and show our recommended practices:

  • "Redux Essentials" tutorial: teaches "how to use Redux, the right way", by building a real-world app using Redux Toolkit
  • "Redux Fundamentals" tutorial: teaches "how Redux works, from the bottom up", by showing how to write Redux code by hand and why standard usage patterns exist, and how Redux Toolkit simplifies those patterns

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.

Collapse
 
kelvinvmwinuka profile image
Kelvin Mwinuka

Thanks for the feedback Mark. I'll be sure to get updated on the latest recommended redux practices