Skip to content

Instantly share code, notes, and snippets.

@osanyin
Created April 29, 2017 19:06
Show Gist options
  • Select an option

  • Save osanyin/e02aa01b2ea1b5b1db2c41f093c240ab to your computer and use it in GitHub Desktop.

Select an option

Save osanyin/e02aa01b2ea1b5b1db2c41f093c240ab to your computer and use it in GitHub Desktop.
function todoApp(state = initialState, action) {
switch (action.type) {
case SET_VISIBILITY_FILTER:
return Object.assign({}, state, {
visibilityFilter: action.filter
})
case ADD_TODO:
return Object.assign({}, state, {
todos: [
...state.todos,
{
text: action.text,
completed: false
}
]
})
default:
return state
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment