Skip to content

Instantly share code, notes, and snippets.

@maximiliangonzalez
Created July 24, 2019 18: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 maximiliangonzalez/5fcd2ffc73652d30cb641a6d3d716e35 to your computer and use it in GitHub Desktop.
Save maximiliangonzalez/5fcd2ffc73652d30cb641a6d3d716e35 to your computer and use it in GitHub Desktop.
A reducer to update the counter in our Redux store
import { createStore } from 'redux';
const initialState = {
count: 0
}
const counterReducer = (state = initialState, action) => {
switch(action.type) {
case 'CHANGE_COUNT':
return {
...state,
count: action.payload
}
default:
return state;
}
};
export default createStore(counterReducer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment