@tremendous/help
    Preparing search index...

    Function usePrevious

    • Custom hook to get the previous value of a state or prop.

      This hook returns the value from the previous render.

      Type Parameters

      • T

      Parameters

      • value: T

        The current value to track.

      Returns undefined | T

      • The previous value.
      const [count, setCount] = useState(0);
      const prevCount = usePrevious(count);

      useEffect(() => {
      console.log('Current count:', count);
      console.log('Previous count:', prevCount);
      }, [count]);