Skip to main content

Function: setState()

function setState<T>(
key,
value,
options?): T

Set a value in the state. When the persist option is set to true, the state will be persisted to disk.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
keystringThe key to set the value for.
valueT | (oldValue) => TThe value to set.
options?SetStateOptionsOptions for setting the state. (Persisting to disk)

Returns

T