Function useAsyncSetEffect

  • This starts an async function and executes another function that performs React state changes if the component is still mounted after the async operation completes. This uses useMounted for handling the mount logic.

    Type Parameters

    • T

    Parameters

    • asyncFunction: (() => Promise<T>)

      async function, it has a copy of the mounted ref so an await chain can be canceled earlier. this should ideally be wrapped with useCallback to prevent rerenders

        • (): Promise<T>
        • Returns Promise<T>

    • onSuccess: ((asyncResult: T) => void)

      this gets executed after async function is resolved and the component is still mounted this should ideally be wrapped with useCallback to prevent rerenders

        • (asyncResult: T): void
        • Parameters

          • asyncResult: T

          Returns void

    • deps: DependencyList = []

      dependency list

    Returns void

Generated using TypeDoc