UNPKG

mendix

Version:

Mendix pluggable widgets API

28 lines (22 loc) 1.07 kB
import { Dispatch } from 'react'; import { SetStateAction } from 'react'; declare type Option_2<T> = T | undefined; export declare type PersistableValue = string | number | boolean | null | PersistableValue[] | { [key: string]: PersistableValue; }; /* Excluded from this release type: useHistoryFrameId */ /** * Returns a stateful value and a function to update it. The value is persisted in app history * and restored when (and if) the page will be returned to. * * @param key Unique identifier of this state within a widget, * @param initialValue The initial value to use if a persistent state hasn't been initialized before and * hasn't been restored from app history. Or a factory of such values. * * @remark Only json-serializable values can be used as persistent state. * @remark {@code undefined} value is not restored from history. * * @beta */ export declare function usePersistentState<T extends Option_2<PersistableValue>>(key: string, initialValue: T | (() => T)): [T, Dispatch<SetStateAction<T>>]; export { }