Skip to content

Instantly share code, notes, and snippets.

@asherccohen
Created July 26, 2019 11:21
Show Gist options
  • Save asherccohen/f54f00dfe8bdb082c80d76fb563407b9 to your computer and use it in GitHub Desktop.
Save asherccohen/f54f00dfe8bdb082c80d76fb563407b9 to your computer and use it in GitHub Desktop.
reducerCreator
function createReducer(initialState, handlers) {
return function reducer(state = initialState, action) {
if (handlers.hasOwnProperty(action.type)) {
return handlers[action.type](state, action)
} else {
return state
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment