Skip to content

Instantly share code, notes, and snippets.

@alexmochu
Created June 30, 2020 11:19
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 alexmochu/352fef66284888ddd0f688391e790eb1 to your computer and use it in GitHub Desktop.
Save alexmochu/352fef66284888ddd0f688391e790eb1 to your computer and use it in GitHub Desktop.
Create Reducer
import { combineReducers } from 'redux';
const initialState = 0;
function count(state = initialState, action) {
switch (action.type) {
case 'INCREMENT':
return state + 1
case 'DECREMENT':
return state - 1
default:
return state;
}
}
const rootReducer = combineReducers({
count
});
export default rootReducer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment