3 ms·
Dan Abramov has said that the Redux docs were written in a deliberately verbose style to get across the ideas, and he didn't really expect people to strictly im
by acemarke 10y ago
Dan Abramov has said that the Redux docs were written in a deliberately verbose style to get across the ideas, and he didn't really expect people to strictly imitate that style. There's a wide variety of approaches and utilities you can use to abstract things as much as you'd like - that's entirely up to you.
- antoaravinth 10y agoAs a beginner in Redux, can you tell me about the other ways to handle these boilerplate?
- acemarke 10y agoA few possible options: - Put all the action types, action types, and reducers for a given portion of the application into one file. This is known as the "ducks" structure, per https://github.com/erikras/ducks-modular-redux https://github.com/erikras/ducks-modular-redux . - Use a utility library like https://github.com/acdlite/redux-actions https://github.com/acdlite/redux-actions to generate action types and action creators for you - Write middleware to manage common logic for your application such as API calls - Skip writing action creators and declaring action constants, and just have components do `this.props.dispatch({type : "SOME_ACTION"})`. I don't recommend the last approach, but it's _totally_ up to you, especially because what you regard as "too much boilerplate" is going to be a personal opinion. One person's "too much boilerplate" is another person's "explicit and easy to trace through the system".