Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaizka-allende/8d5001837415e41fde297592e8873c82 to your computer and use it in GitHub Desktop.
Save gaizka-allende/8d5001837415e41fde297592e8873c82 to your computer and use it in GitHub Desktop.
combineReducers for useReducer
const combineReducers = reducers => (
state,
action,
) => reducers.reduce(
(
newState,
reducer,
) => reducer(
newState,
action,
),
state,
);
export default combineReducers;
and I call it like this:
const [state, dispatch] = useReducer(
combineReducers(
[
reduder1,
reducer2,
],
),
{
...initialAuctionState,
...initialLinkedDealsState,
},
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment