UNPKG

rooks

Version:

Essential React custom hooks ⚓ to super charge your components!

17 lines (16 loc) 482 B
import { useRef, useEffect } from "react"; /** * usePreviousImmediate hook for React * * @param currentValue The value whose previous value is to be tracked * @returns The previous value * @see https://react-hooks.org/docs/usePreviousImmediate */ function usePreviousImmediate(currentValue) { var previousRef = useRef(null); useEffect(function () { previousRef.current = currentValue; }); return previousRef.current; } export { usePreviousImmediate };