Logos DX
    Preparing search index...

    Function useAsync

    • Generic async hook — wraps any async function with loading/error/data state. Auto-executes on mount and when deps change.

      If the function returns a FetchResponse (from FetchEngine methods), the .data property is automatically unwrapped.

      const { data, loading, error } = useAsync(
          () => myApi.getUsers(page),
          [page],
      );
      

      Type Parameters

      • T = unknown
      • E extends Record<string, any> = Record<string, any>

      Parameters

      • fn: () => Promise<any>

        Async function to execute

      • deps: DependencyList

        React dependency list — re-executes when these change

      • Optionaloptions: AsyncOptions<E>

        skip, pollInterval, invalidateOn

      • Optionalobserver: ObserverEngine<E>

        Optional ObserverEngine for invalidateOn support

      Returns QueryResult<T>