Sanity Library Reference Docs
    Preparing search index...

    Function useDidUpdate

    • Beta

      A hook for doing side effects as a response to a change in a hook value between renders

      Type Parameters

      • T

      Parameters

      • current: T

        The value you want to respond to changes in.

      • didUpdate: (previous: T, current: T) => void

        Callback to run when the value changes.

      • Optionalcompare: (previous: T, current: T) => boolean

      Returns void

      useDidUpdate(hasFocus, (hadFocus, hasFocus) => {
      if (hasFocus) {
      scrollIntoView(elementRef.current)
      }
      })