2 ms·
It's unfortunate that the Redux docs have led many (including myself) to think that Redux reducers means "switch statement". See http://redux.js.org/docs/basics
by licyeus 10y ago
It's unfortunate that the Redux docs have led many (including myself) to think that Redux reducers means "switch statement". See http://redux.js.org/docs/basics/Reducers.html http://redux.js.org/docs/basics/Reducers.html under "Note on switch and Boilerplate".
Your reducer can be whatever you want it to be as long as it does not produce side-effects. I use something like https://65535th.com/move-away/ https://65535th.com/move-away/
Additionally, as roughcoder points out elsewhere in thread, using the object spread syntax (available in babel-preset-stage-2 or babel-plugin-transform-object-rest-spread) minimizes some additional boilerplate.
- acemarke 10y agoJust for the record, the Redux docs already describe this pattern: http://redux.js.org/docs/recipes/ReducingBoilerplate.html#generating-reducers http://redux.js.org/docs/recipes/ReducingBoilerplate.html#ge...