Created
May 10, 2019 08:41
-
-
Save kirpalmakanga/45f1b29ef6779b0d279cad65b7f4a972 to your computer and use it in GitHub Desktop.
Little helper for reducer generation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createReducer = (initialState = {}, handlers = {}) => ( | |
state = {}, | |
action = {} | |
) => | |
handlers.hasOwnProperty(action.type) | |
? handlers[action.type](state, action) | |
: { ...initialState, ...state }; | |
export default createReducer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment