Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// Wrap every object before passing to createReducer
export default function createReducer(initialState: ?{}, handlers: {}) {
return function reducer(state: ?{} = initialState, action: {type: string, payload: Object}) {
return typeof handlers[action.type] === 'function'
? handlers[action.type](state, action)
: state;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment