multiple reducers in context api
const initialState = {
random: { value: 0 },
counter: 0,
}
const combineReducers = reducers => {
return (state, action) => {
return Object.keys(reducers).reduce(
(acc, prop) => {
return ({
...acc,
...reducers[prop]({ [prop]: acc[prop] }, action),
})
},
state
)
}
}
export { initialState, combineReducers }