Skip to content

Commit

Permalink
Correct two typos.
Browse files Browse the repository at this point in the history
Also, the first sentence of the paragraph was very long. Given the references are also hard to follow in an English sentences, due to the meta level, I preferred to split it
  • Loading branch information
Arthur-Milchior authored Sep 18, 2023
1 parent 75e004d commit 426bbd7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion website/docs/pitfalls.md
Original file line number Diff line number Diff line change
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 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:
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 of the outer produce; those changes will only be visible in the output that the inner `produce` returns. 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 of the inner produce isn't used. The correct way to use nested producers is:

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

0 comments on commit 426bbd7

Please sign in to comment.