DEV Community

Discussion on: How to use Redux in ReactJS with real-life examples

Collapse
 
markerikson profile image
Mark Erikson

Hi, I'm a Redux maintainer. A few quick bits of feedback:

  • The current version of React-Redux is v7.1.1. The v5.x line is being maintained for folks who haven't yet migrated, but you should be using 7.x.
  • Prefer using the "object shorthand" form of mapDispatch. There's almost never a good reason to write mapDispatch as a function.
  • Don't write mapState functions that return the entire state value (and in that first example, the ...state isn't doing anything useful either). A connected component should only extract the bare minimum pieces of state that it needs, to avoid unnecessary re-renders when unrelated data changes.

Finally, I'd strongly encourage you to try our new Redux Starter Kit package. 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 without writing any action creators or action types by hand. It just hit 1.0, and is our recommended way to write Redux logic.

redux-starter-kit.js.org

Collapse
 
einazare profile image
Nazare Emanuel-Ioan

Hello Mark,

Thank you for your feedback.
I wasn't expecting one of the Redux maintainers to come with feedback, but I agree with everything, this tutorial should be updated.
I'll see when I have some free time to take a look at the Redux Starter Kit package and see how I can integrate it into our project.

Once again, thank you for your time.

Kind regards,
Manu