Download react-use/src/misc/hookState.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 926 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-use/src/misc/hookState.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-use/src/misc/hookState.ts
-
curl -L -o hookState.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-use/src/misc/hookState.ts
926 Bytes
| export type IHookStateInitialSetter<S> = () => S; | |
| export type IHookStateInitAction<S> = S | IHookStateInitialSetter<S>; | |
| export type IHookStateSetter<S> = ((prevState: S) => S) | (() => S); | |
| export type IHookStateSetAction<S> = S | IHookStateSetter<S>; | |
| export type IHookStateResolvable<S> = S | IHookStateInitialSetter<S> | IHookStateSetter<S>; | |
| export function resolveHookState<S>(nextState: IHookStateInitAction<S>): S; | |
| export function resolveHookState<S, C extends S>( | |
| nextState: IHookStateSetAction<S>, | |
| currentState?: C | |
| ): S; | |
| export function resolveHookState<S, C extends S>( | |
| nextState: IHookStateResolvable<S>, | |
| currentState?: C | |
| ): S; | |
| export function resolveHookState<S, C extends S>( | |
| nextState: IHookStateResolvable<S>, | |
| currentState?: C | |
| ): S { | |
| if (typeof nextState === 'function') { | |
| return nextState.length ? (nextState as Function)(currentState) : (nextState as Function)(); | |
| } | |
| return nextState; | |
| } | |