Create the next immutable state by mutating the current one
setUseStrictShallowCopy("class_only")
to revert to the old behavior. For more details see https://immerjs.github.io/immer/complex-objects#semantics-in-detail
Proxy
, Reflect
, Symbol
and Map
and Set
.createDraft
and finishDraft
.enableES5()
, you SHOULD NOT upgrade Immer. enableES5
has been removed.produce
is no longer exposed as the default
export. This improves eco system compatibility, and makes sure that there is only one correct way of doing thingsenableAllPlugins
has been removed, use enablePatches(); enableMapSet()
insteadlength
property, in accordance with JSON spec. Thanks kshramt for implementing this in #964!Overall, there is a rough performance increase of 33% for Immer (and in some cases significantly higher), and the (non gzipped) bundle size has reduced from 16 to 11.5 KB, while the the minimal gzipped import of just produce
has remained roughly the same at 3.3 KB.
For more details, see #1015
enableES5()
call, don't migrateuseStrictShallowCopy(true)
at startupimport produce from "immer"
with import {produce} from "immer"
enableAllPlugins()
with enablePatches(); enableMapSet();
to be more specific and smoothen future migrations.createDraft
instead. Roughly:const newState = await produce(oldState, recipe)
// becomes
const draft = createDraft(oldState)
await recipe(draft)
const newState = finishDraft(draft)