Description
Resolution: use Redux Toolkit
The ideas in this thread eventually turned into our official Redux Toolkit package. It includes utilities to simplify many common Redux use cases, including store setup, reducer definition, immutable update logic, creating entire "slices" of state automatically without writing any action creators or action types by hand, and even automatic data fetching and caching with the "RTK Query" API.
For more details on what problems Redux Toolkit is meant to solve, see the "Vision for Redux Toolkit" manifesto I wrote .
The number one complaint I see about Redux is that there's "too much boilerplate". I also frequently see complaints that there's too much to learn, too many other addons that are needed to do anything useful, and too many aspects where Redux doesn't have any opinion and therefore doesn't offer any kind of built-in guidance.
I just had a discussion with @tannerlinsley regarding several of these aspects. We discussed the Jumpstate library, which is an abstraction layer around Redux, and how it was intended to ease the learning curve, as well as various philosophical opinions about what constitutes "good" Redux usage.
Out of that, we came up with several questions that I would like to bring up for wider discussion:
Key points
Boilerplate / Verbosity
- Redux is not intended to be the "most concise way of doing things", but rather to make data flow obvious and readable
- Docs are written in a deliberately verbose style for clarity and learning, and not specifically intended as "the one true way to write Redux code", but that style has been somewhat blindly adopted (or, sometimes, resulted in rejecting Redux)
- Frequent complaints about "boilerplate", such as "too many files", "use of action creators", etc
Abstractions and Learning
- The core Redux library itself is effectively feature-complete, but there's lots of interesting addons and tools being built by the community
- Various abstraction libs have been built to "ease learning curve" or "make things more OOP", but most of these are not really "idiomatic" Redux usage
- Redux learning curve can be steep, but once you grasp concepts, the need for abstraction layers often goes away
Problems
- What are the "boilerplate" complaints mostly about?
- What are the hardest aspects of Redux for new learners?
- What are the "no opinions" areas that cause problems for people?
Potential Solutions
- What would idiomatic Redux usage with "less boilerplate" look like? How can we provide solutions to those complaints?
- What possible abstractions could be created that simplify the process of learning and usage, but without actually hiding Redux (and would hopefully provide a migration/learning path to "base" Redux)?
- How much of this could be solved with improved docs in some way?
I would like to invite the community to offer up complaints, pain points, and concerns about using Redux, and hopefully also provide suggestions and ideas for solving those problems as well.