Skip to content

Commit 0789c4f

Browse files
christoph-jerolimovmarkerikson
authored andcommitted
Fix intention and add missing payload extraction (#79)
1 parent f2af581 commit 0789c4f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

docs/api/createReducer.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,15 @@ const todosReducer = createReducer([], {
8484
[addTodo]: (state, action) => {
8585
// This push() operation gets translated into the same
8686
// extended-array creation as in the previous example.
87-
state.push(todo)
87+
const todo = action.payload
88+
state.push(todo)
8889
},
8990
[toggleTodo]: (state, action) => {
9091
// The "mutating" version of this case reducer is much
9192
// more direct than the explicitly pure one.
9293
const index = action.payload
93-
const todo = state[index]
94-
todo.completed = !todo.completed
94+
const todo = state[index]
95+
todo.completed = !todo.completed
9596
}
9697
})
9798
```

0 commit comments

Comments
 (0)