DEV Community

How to use Redux in ReactJS with real-life examples

Creative Tim on October 29, 2019

Since I started to work with ReactJS, at Creative-Tim, I’ve only used it to create simple react apps, or templates if you will. I have used ReactJS...
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

Collapse
 
dennisat profile image
Dennis

Have you tried Dynadux? github.com/aneldev/dynadux It is much simpler and powerful.