hooks-belt
Version:
A comprehensive collection of useful React hooks for common use cases
21 lines • 622 B
TypeScript
/**
* A hook that returns the previous value of a state or prop.
* Useful for comparing current and previous values in useEffect.
*
* @param value - The current value
* @returns The previous value (undefined on first render)
*
* @example
* ```tsx
* const [count, setCount] = useState(0)
* const previousCount = usePrevious(count)
*
* useEffect(() => {
* if (previousCount !== undefined && count > previousCount) {
* console.log('Count increased!')
* }
* }, [count, previousCount])
* ```
*/
export declare function usePrevious<T>(value: T): T | undefined;
//# sourceMappingURL=usePrevious.d.ts.map