Skip to content

Commit

Permalink
Merge pull request #544 from delanni/patch-1
Browse files Browse the repository at this point in the history
Add section about using classes with immer
  • Loading branch information
mweststrate committed Feb 25, 2020
2 parents 21c1597 + 30e0f54 commit b94c34f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions docs/pitfalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ title: Pitfalls
1. Always try to pull `produce` 'up', for example `for (let x of y) produce(base, d => d.push(x))` is exponentially slower than `produce(base, d => { for (let x of y) d.push(x)})`
1. It is possible to return values from producers, except, it is not possible to return `undefined` that way, as it is indistinguishable from not updating the draft at all! If you want to replace the draft with `undefined`, just return `nothing` from the producer.
1. Immer [does not support exotic objects](https://github.com/immerjs/immer/issues/504) such as window.location.
1. You will need to enable your own classes to work properly with Immer. For docs on the topic, check out the section on [working with complex objects](https://immerjs.github.io/immer/docs/complex-objects).
1. Note that data that comes from the closure, and not from the base state, will never be drafted, even when the data has become part of the new draft:

```javascript
Expand Down

0 comments on commit b94c34f

Please sign in to comment.