Be notified of new releases
Create your free GitHub account today to subscribe to this repository for new releases and build software alongside 40 million developers.Sign up
This release introduces first class support for Maps and Sets!
BREAKING CHANGE: Maps and Sets are treated differently now; they will no longer directly mutated when updated inside a draft
Some things to keep in mind:
- Example: https://immerjs.github.io/immer/docs/complex-objects
- Inside recipes, you can directly modify Maps and Sets with methods like
- Those methods do mutate draft Maps and Sets, but won't actually change their originals!
- Immer does not polyfill Map and Set automatically in environments where those aren't available out of the box
- Maps and Sets are supported both in ES5 and Proxy mode
autoFreezeis enabled, the maps and sets returned from a producer will be artificially frozen by making their mutative APIs unusable
- Non primitive keys for Maps, and non primitive values for Sets are supported. However, we strongly recommend to not combine non-primitive keys to Maps with patches, for reasons expressed below.
- TypeScript support for storing immutable types inside Maps and Sets, and converting them to
Draft's, is limited, see #448 for details
- Since JSON-patch standard doesn't offer support for Sets or Maps, it is not entirely clear how mutations to those are best described by patches, so this might be refined in the future. See also #450