Skip to content

Instantly share code, notes, and snippets.

@gdborton
Last active October 25, 2015 16:22
Embed
What would you like to do?
// Straight from documentation.
const reducer = combineReducers({
a: doSomethingWithA,
b: processB,
c: c
});
// This is functionally equivalent.
function reducer(state, action) {
return {
a: doSomethingWithA(state.a, action),
b: processB(state.b, action),
c: c(state.c, action)
};
}
// Simple change to pass the entire state to each reducer.
// You have to be extra careful to keep state immutable here.
function reducer(state, action) {
return {
a: doSomethingWithA(state.a, action, state),
b: processB(state.b, action, state),
c: c(state.c, action, state)
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment