Open amsterdamharu opened 4 years ago
@amsterdamharu you can use https://github.com/ahungrynoob/use-root-reducer
Why not just use the useRef hook to solve this? This PR seems overly complicated to me, maybe I'm missing something.
const { current: dispatch } = useRef(action =>
Object.keys(combinedReducers)
.map(key => combinedReducers[key][1])
.forEach(fn => fn(action));
);
Dispatch has a different reference every time you call createDispatch. That is not how React.useReducer works and this should have consistant behavior.
Reference to issiue: https://github.com/the-road-to-learn-react/use-combined-reducers/issues/4