reduce-reducers
Reduce multiple reducers into a single reducer from left to right
Install
npm install reduce-reducers
Usage
; const initialState = A: 0 B: 0 ; const addReducer = ...state A: stateA + payload ;const multReducer = ...state B: stateB * payload ; const reducer = ; const state = A: 1 B: 2 ;const payload = 3; ; // { A: 4, B: 6 }
FAQ
Why?
Originally created to combine multiple Redux reducers that correspond to different actions (e.g. like this). Technically works with any reducer, not just with Redux, though I don't know of any other use cases.
reduceReducers
and combineReducers
?
What is the difference between This StackOverflow post explains it very well: https://stackoverflow.com/a/44371190/5741172