When should I learn Redux?
We recommend that most new learners should focus on learning React first, and wait to learn Redux until after you're already comfortable with React. That way, there's fewer new concepts to learn at once, and it's more clear what concepts are part of React and what concepts are part of Redux. You'll also have a better understanding of how using Redux fits into a React app, and why Redux can be useful.
- Deciding What Not To Learn
- How to learn web frameworks
- Redux vs MobX vs Flux vs... Do you even need that?
- Ask HN: Overwhelmed with learning front-end, how do I proceed?
- Twitter: If you want to teach someone to use an abstraction...
- Twitter: it was never intended to be learned before...
- Twitter: Learning Redux before React?
- Twitter: The first time I used React, people told me I needed Redux...
- Twitter: This was my experience with Redux...
- Dev.to: When is it time to use Redux?
When should I use Redux?
Not all apps need Redux. It's important to understand the kind of application you're building, the kinds of problems that you need to solve, and what tools can best solve the problems you're facing.
Redux helps you deal with shared state management, but like any tool, it has tradeoffs. It's not designed to be the shortest or fastest way to write code. It's intended to help answer the question "When did a certain slice of state change, and where did the data come from?", with predictable behavior. There are more concepts to learn, and more code to write. It also adds some indirection to your code, and asks you to follow certain restrictions. It's a trade-off between short term and long term productivity.
As Pete Hunt, one of the early contributors to React, says:
You'll know when you need Flux. If you aren't sure if you need it, you don't need it.
Similarly, Dan Abramov, one of the creators of Redux, says:
I would like to amend this: don't use Redux until you have problems with vanilla React.
Redux is most useful when in cases when:
- You have large amounts of application state that are needed in many places in the app
- The app state is updated frequently
- The logic to update that state may be complex
- The app has a medium or large-sized codebase, and might be worked on by many people
- You need to see how that state is being updated over time
There are also many other tools available that can help solve some of the same problems Redux does: state management, caching fetched server data, and passing data through the UI.
If you're not sure whether Redux is a good choice for your app, these resources give some more guidance:
In the end, Redux is just a tool. It's a great tool, and there are some great reasons to use it, but there are also reasons you might not want to use it. Make informed decisions about your tools, and understand the tradeoffs involved in each decision.
- When (and when not) to reach for Redux
- The Tao of Redux, Part 1 - Implementation and Intent
- You Might Not Need Redux
- The Case for Flux
- Twitter: Don't use Redux until...
- Twitter: Redux is designed to be predictable, not concise
- Twitter: Redux is useful to eliminate deep prop passing
- Twitter: Don't use Redux unless you're unhappy with local component state
- Twitter: You don't need Redux if your data never changes
- Twitter: If your reducer looks boring, don't use redux
- Reddit: You don't need Redux if your app just fetches something on a single page
- Stack Overflow: Why use Redux over Facebook Flux?
- Stack Overflow: Why should I use Redux in this example?
- Stack Overflow: What could be the downsides of using Redux instead of Flux?
- Stack Overflow: When should I add Redux to a React app?
- Stack Overflow: Redux vs plain React?
- Twitter: Redux is a platform for developers to build customized state management with reusable things
Can Redux only be used with React?
Redux can be used as a data store for any UI layer. The most common usage is with React and React Native, but there are bindings available for Angular, Angular 2, Vue, Mithril, and more. Redux simply provides a subscription mechanism which can be used by any other code. That said, it is most useful when combined with a declarative view implementation that can infer the UI updates from the state changes, such as React or one of the similar libraries available.
Do I need to have a particular build tool to use Redux?
<script> tag. As the relevant pull request says:
The new Counter Vanilla example is aimed to dispel the myth that Redux requires Webpack, React, hot reloading, sagas, action creators, constants, Babel, npm, CSS modules, decorators, fluent Latin, an Egghead subscription, a PhD, or an Exceeds Expectations O.W.L. level.
Nope, it's just HTML, some artisanal
<script>tags, and plain old DOM manipulation. Enjoy!