Skip to content

Instantly share code, notes, and snippets.

@bmeurer
Last active March 14, 2017 05:10
Show Gist options
  • Save bmeurer/d0454b9c68986d011dd661d145e18938 to your computer and use it in GitHub Desktop.
Save bmeurer/d0454b9c68986d011dd661d145e18938 to your computer and use it in GitHub Desktop.
const todo = (state = {}, action) => {
switch (action.type) {
case 'ADD_TODO':
return {
id: action.id,
text: action.text,
completed: false
}
case 'TOGGLE_TODO':
if (state.id !== action.id) {
return state
}
return Object.assign({}, state, {
completed: !state.completed
})
default:
return state
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment