Extracting the original state from a draft
Immer exposes a named export original
that will get the original object from the proxied instance inside produce
(or return undefined
for unproxied values). A good example of when this can be useful is when searching for nodes in a tree-like state using strict equality.
Just want to know if a value is a proxied instance? Use the isDraft
function! Note that original
cannot be invoked on objects that aren't drafts.