Skip to content

useImmutable

This hook has the same contracts as useQuery. However, instead of wrapping useSWR, it wraps useSWRImmutable. This immutable hook disables automatic revalidations but is otherwise identical to useSWR.

ts
import createClient from "openapi-fetch";
import { createQueryHook } from "swr-openapi";
import type { paths } from "./my-schema";

const useImmutable = createImmutableHook(client, "my-api");

const { data, error, isLoading, isValidating, mutate } = useImmutable(
  path,
  init,
  config,
);

API

Parameters

Identical to useQuery parameters.

Returns

Identical to useQuery returns.