Skip to content

Latest commit

 

History

History
68 lines (39 loc) · 1.12 KB

current.md

File metadata and controls

68 lines (39 loc) · 1.12 KB

mutativeDocs


mutative / current

Function: current()

current(target)

current<T>(target): T

current(draft) to get current state in the draft mutation function.

Example

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' });
  },
);

Type Parameters

T extends object

Parameters

target: Draft<T>

Returns

T

Defined in

current.ts:120

current(target)

current<T>(target): T

Type Parameters

T extends object

Parameters

target: T

Returns

T

Deprecated

You should call current only on Draft<T> types.

Defined in

current.ts:122