Skip to content

Instantly share code, notes, and snippets.

@mizchi
Created August 27, 2015 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mizchi/ad20d815431df89f463f to your computer and use it in GitHub Desktop.
Save mizchi/ad20d815431df89f463f to your computer and use it in GitHub Desktop.
const rootReducer = combineReducers({
counter: (state = 0, action) => {
switch (action.type) {
case INCREMENT_COUNTER_IF_ODD:
if (state % 2 === 1) {
return state + 1;
} else {
return state;
}
case INCREMENT_COUNTER:
return state + 1;
case DECREMENT_COUNTER:
return state - 1;
default:
return state;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment