Things To Learn Before Redux
With React’s new context API you can go a long way with a plain old react app before things become tedious. I encourage you to learn how to use the new context API before you reach for redux.
I also have tremendous respect for component setState. Learn how to use it before you start with redux. Did you know setState takes a callback? Did you know you can pass setState an updater function? Did you know that you can declare state changes outside of a component?
Using Redux before you understand how to use higher order components can also be a little confusing. Before you start using redux understand higher order components well enough to know when it’s better to use a render prop.
If you’re comfortable with context, you’ve mastered setState batching and you know what a prop-namespace-clash is, and you are still finding you app hard to manage then you are going to love redux.
Redux doesn’t just give you access to any piece of state anywhere in your app, it also pushes you to rely on pure functions. This makes things a lot easier to test, and gets everyone on a team using the same approach.
Human Redux by Henrik Joreteg is the single the best book I have read on learning redux. Well worth the money. If you can’t afford it then google ‘Learn Redux with Dan Abramov’ for one of the best free resources for learning redux on the web.
Links:
- You Might Not Need Redux .
- Learn how to use React’s new context API.
- setState takes a callback.
- You can pass setState an updater function.
- You can declare state changes outside of a component.
- “Read this and you’ll know more about setState than 90% of react developers”. - Kent C. Dodds
- Redux Docs.
- Learn Redux with Dan Abramov.
- Human Redux by Henrik Joreteg.