Skip to content

Commit

Permalink
chore(docs): Fix typo in pitfalls.md (#729)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfranty committed Jan 11, 2021
1 parent 5379cdd commit d8121d6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/pitfalls.md
Expand Up @@ -61,7 +61,7 @@ The set of patches generated by Immer should be correct, that is, applying them

### Always use the result of nested producers

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:
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:

```javascript
produce(state, draft => {
Expand Down

0 comments on commit d8121d6

Please sign in to comment.