Skip to content

Instantly share code, notes, and snippets.

@nesbtesh
Created August 24, 2016 13:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nesbtesh/95d93c52be6c1a2a5c8cb3b47c76c5fe to your computer and use it in GitHub Desktop.
Save nesbtesh/95d93c52be6c1a2a5c8cb3b47c76c5fe to your computer and use it in GitHub Desktop.
Create Reducer Redux
export function createReducer(initialState, reducerMap) {
return (state = initialState, action) => {
const reducer = reducerMap[action.type];
return reducer
? reducer(state, action.payload)
: state;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment