Created
March 25, 2016 17:40
-
-
Save dmachat/d1f883e57eb3fd5a1193 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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