Skip to content

Instantly share code, notes, and snippets.

@andrewjmead
Created July 6, 2016 13:17
Show Gist options
  • Save andrewjmead/9012cb6d66b6750b6fd45a055402d7fa to your computer and use it in GitHub Desktop.
Save andrewjmead/9012cb6d66b6750b6fd45a055402d7fa to your computer and use it in GitHub Desktop.
Yann - Reducer
case 'TOGGLE_TODO':
return state.map((todo) => {
if (todo.id === action.id) {
var nextCompleted = !todo.completed;
return {
...todo,
completed: nextCompleted,
completedAt: nextCompleted ? moment().unix() : undefined
};
}
return todo;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment