Map and Set
⚠ Since version 6 support for Map
s and Set
s has to be enabled explicitly by calling enableMapSet()
once when starting your application.
Plain objects, arrays, Map
s and Set
s are always drafted by Immer. An example of using Maps with immer:
Maps and Sets that are produced by Immer will be made artificially immutable. This means that they will throw an exception when trying mutative methods like set
, clear
etc. outside a producer.
Note: The keys of a map are never drafted! This is done to avoid confusing semantics and keep keys always referentially equal