Redux FAQ: General
General
Further information
Articles
- How to learn web frameworks
DiscussionsAsk HN: Overwhelmed with learning front-end, how do I proceed?
- Twitter: it was never intended to be learned before…
- Twitter: The first time I used React, people told me I needed Redux…
- Dev.to: When is it time to use Redux?
The need to use Redux should not be taken for granted.
As Pete Hunt, one of the early contributors to React, says:
In general, use Redux when you have reasonable amounts of data changing over time, you need a single source of truth, and you find that approaches like keeping everything in a top-level React component's state are no longer sufficient.
However, it's also important to understand that using Redux comes with 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. It does so by asking you to follow specific constraints in your application: store your application's state as plain data, describe changes as plain objects, and handle those changes with pure functions that apply updates immutably. This is often the source of complaints about "boilerplate". These constraints require effort on the part of a developer, but also open up a number of additional possibilities (such as store persistence and synchronization).
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.
Further information
Documentation
Introduction: Motivation
Articles- Twitter: Redux is designed to be predictable, not concise
- Twitter: Don't use Redux unless you're unhappy with local component state
- Twitter: If your reducer looks boring, don't use redux
- Stack Overflow: Why use Redux over Facebook Flux?
- Stack Overflow: What could be the downsides of using Redux instead of Flux?
- Twitter: Redux is a platform for developers to build customized state management with reusable things
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.
Redux is originally written in ES6 and transpiled for production into ES5 with Webpack and Babel. You should be able to use it regardless of your JavaScript build process. Redux also offers a UMD build that can be used directly without any build process at all. The example demonstrates basic ES5 usage with Redux included as a tag. As the relevant pull request says: