4 ms·
As a beginner in Redux, can you tell me about the other ways to handle these boilerplate?
by antoaravinth 9y ago
As a beginner in Redux, can you tell me about the other ways to handle these boilerplate?
- acemarke 9y 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".