Skip to content

Commit 15a449a

Browse files
Correct two typos. (#1072)
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
1 parent 3864ad2 commit 15a449a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

website/docs/pitfalls.md

Lines changed: 1 addition & 1 deletion
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 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:
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 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:
6565

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

0 commit comments

Comments
 (0)