Created
August 24, 2016 13:32
-
-
Save nesbtesh/95d93c52be6c1a2a5c8cb3b47c76c5fe to your computer and use it in GitHub Desktop.
Create Reducer Redux
This file contains hidden or 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
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