mutative • Docs
mutative / current
current<
T
>(target
):T
current(draft)
to get current state in the draft mutation function.
import { create, current } from '../index';
const baseState = { foo: { bar: 'str' }, arr: [] };
const state = create(
baseState,
(draft) => {
draft.foo.bar = 'str2';
expect(current(draft.foo)).toEqual({ bar: 'str2' });
},
);
• T extends object
• target: Draft
<T
>
T
current<
T
>(target
):T
• T extends object
• target: T
T
You should call current only on Draft<T>
types.