UNPKG

reactuals

Version:

A useful package providing a collection of 50+ React hooks and utilities to simplify React development.

13 lines (12 loc) 294 B
import { useEffect, useRef } from "react"; /** * Returns the previous value of a variable. * @param value - Current value */ export function usePrevious(value) { const ref = useRef(undefined); useEffect(() => { ref.current = value; }, [value]); return ref.current; }