Skip to content

Instantly share code, notes, and snippets.

@cpv123
Last active January 7, 2020 08:17
Show Gist options
  • Save cpv123/53018a24cd816a3a60d5d59085c08dea to your computer and use it in GitHub Desktop.
Save cpv123/53018a24cd816a3a60d5d59085c08dea to your computer and use it in GitHub Desktop.
import produce from 'immer'
const initialState = {
todos: {
'a': { id: 'a', description: '...', isComplete: false },
'b': { id: 'b', description: '...', isComplete: false }
}
}
const reducer = (state, action) => (
produce(state, draft => {
draft.todos[action.todoId].isComplete = action.payload
})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment