@playlive/react-data
    Preparing search index...

    Function useFetch

    • Core fetch-on-mount hook with cancellation, polling, and retry.

      Every domain hook in @playlive/react-data is a thin shell around this primitive. Surface lifted directly out of TanStack Query's useQuery for API-compatibility.

      behavior:

      • key changes ⇒ abort in-flight + refetch.
      • enabled = false ⇒ never fetch + reset isLoading to false.
      • refetchInterval > 0 ⇒ poll on a timer; the timer is reset after each successful resolve (no overlapping fetches).
      • Errors trigger up to retry retries with exponential backoff.
      • Unmount aborts any in-flight request and cancels pending timers.

      Type Parameters

      • T

        Resolved payload type.

      Parameters

      • key: readonly unknown[]

        Stable identity for the request. Any change (deep equality on the serialized form) triggers a refetch.

      • fetcher: Fetcher<T>

        Async function receiving { signal }.

      • options: UseFetchOptions = {}

        Standard UseFetchOptions.

      Returns UseFetchResult<T>

      const { data, error, isLoading, refetch } = useFetch(
      ["campaign", id],
      ({ signal }) => fetchCampaign({ id }, { signal }),
      { enabled: !!id, refetchInterval: 5_000 }
      );