CupThread React Native & Expo SDK - v0.1.0
    Preparing search index...

    Function useAsyncData

    • Shared load-state hook tracking data / isLoading / isRefreshing / error for a single async fetch, with abort handling, retry (reload), and pull-to-refresh (refresh) that never blanks out existing data.

      The fetcher should be wrapped in useCallback by the caller; when its identity changes (e.g. because an input changed) the data is reloaded.

      Type Parameters

      • T

      Parameters

      • fetcher: (signal: AbortSignal) => Promise<T>

        Async function that performs the fetch.

      • options: UseAsyncDataOptions<T> = {}

        Hook configuration options.

      Returns UseAsyncDataResult<T>

      State and callbacks for rendering load / error / data states.

      const fetchEntries = useCallback(
      (signal: AbortSignal) => client.fetchChangelog({ signal }),
      [client]
      );
      const { data: entries, isLoading, error, reload } = useAsyncData(fetchEntries);