UNPKG

state-hooks

Version:

Essential set of React Hooks for convenient state management.

16 lines (15 loc) 440 B
/** * Tracks previous state of a value. * * @param value Props, state or any other calculated value. * @returns Value from the previous render of the enclosing component. * * @example * function Component() { * const [count, setCount] = useState(0); * const prevCount = usePrevious(count); * // ... * return `Now: ${count}, before: ${prevCount}`; * } */ export default function usePrevious<T>(value: T): T | undefined;