Skip to main content

useLatest

Callable

  • useLatest<T>(value: T): React.MutableRefObject<T>

  • This is mostly useful to get access to the latest value of some props or state inside an asynchronous callback, instead of that value at the time the callback was created from.


    Type parameters

    • T

    Parameters

    • value: T

      The value to store in a ref.

    Returns React.MutableRefObject<T>