UNPKG

@lyonph/preact-hooks

Version:

Collection of useful Preact Hooks

8 lines (7 loc) 585 B
import { ShouldUpdate } from './useDependencyChanged'; export declare type RefreshStateInitialAction<T> = () => T; export declare type RefreshStateInitial<T> = T | RefreshStateInitialAction<T>; export declare type RefreshStateAction<T> = (prev: T) => T; export declare type RefreshStateSetState<T> = T | RefreshStateAction<T>; export declare type RefreshStateDispatch<T> = (action: RefreshStateSetState<T>) => void; export default function useFreshState<T, R>(initialState: RefreshStateInitial<T>, dependencies: R, shouldUpdate?: ShouldUpdate<R>): [T, RefreshStateDispatch<T>];