If you have a bunch of complex reducer logic which you want to slowly migrate over to Riduce, there's an easy way to do this!
All you need to do is wrap your old root reducer in a new function with a ternary:
import initialState from './initialState';
import oldRootReducer from './oldRootReducer';
import riduceReducer from './riduceReducer';
const newRootReducer = (state = initialState, action) => action.leaf
? riduceReducer(state)
: oldReducer(state)
Here's why this works:
leaf
property (this is an implementation detail)leaf
property)mainReducer
:
leaf
property is present, pass it to the riduceReducer
, which will know how to handle itoldReducer