Skip to content

Commit d8121d6

Browse files
authoredJan 11, 2021
chore(docs): Fix typo in pitfalls.md (#729)
1 parent 5379cdd commit d8121d6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎docs/pitfalls.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ The set of patches generated by Immer should be correct, that is, applying them
6161

6262
### Always use the result of nested producers
6363

64-
Nested `produce` calls are supported, but note that `produce` will _always_ produce a new state, so even when passing a draft to a nested produce, the changes made by the inner produce won't be visibile in the draft that was passed it, but only in the output that is produced. In other words, when using nested produce, you get a draft of a draft and the result of the inner produce should be merged back into the original draft (or returned). For example `produce(state, draft => { produce(draft.user, userDraft => { userDraft.name += "!" })})` won't work as the output if the inner produce isn't used. The correct way to use nested producers is:
64+
Nested `produce` calls are supported, but note that `produce` will _always_ produce a new state, so even when passing a draft to a nested produce, the changes made by the inner produce won't be visible in the draft that was passed it, but only in the output that is produced. In other words, when using nested produce, you get a draft of a draft and the result of the inner produce should be merged back into the original draft (or returned). For example `produce(state, draft => { produce(draft.user, userDraft => { userDraft.name += "!" })})` won't work as the output if the inner produce isn't used. The correct way to use nested producers is:
6565

6666
```javascript
6767
produce(state, draft => {

0 commit comments

Comments
 (0)
Please sign in to comment.