Skip to content

Instantly share code, notes, and snippets.

@dmachat
Created March 25, 2016 17:40
Show Gist options
  • Save dmachat/d1f883e57eb3fd5a1193 to your computer and use it in GitHub Desktop.
Save dmachat/d1f883e57eb3fd5a1193 to your computer and use it in GitHub Desktop.
// initial app state can be supplied (or bootstrapped) here
const defaultState = {
items: [],
};
/**
* @params
* state {object} - this is the current state of this branch of the store (store.data)
* action {object} - the instructions from the component, commonly { type, data }
*/
export default function(state = defaultState, action) {
switch (action.type) {
case ‘ADD_DATA’:
// we're changing the value of store.data here
// to add the new data to the list
return {
items: state.items.concat(action.data)
};
break;
case default:
return state; // don't change
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment