real-enums
    Preparing search index...

    Function withEnums

    • Wraps an SWR fetcher so its data arrives as enum instances, typed: useSWR('/orders/1', withEnums<Order>(fetchJson, { state: OrderState })).

      Enum instances are singletons, so SWR's comparison sees a revalidation with the same payload as unchanged and keeps the same object.

      Type Parameters

      • T
      • Args extends unknown[] = [string]

      Parameters

      Returns (...args: Args) => Promise<T>