Skip to content

Latest commit

 

History

History
35 lines (23 loc) · 951 Bytes

use-immutable.md

File metadata and controls

35 lines (23 loc) · 951 Bytes
title
useImmutable

{{ $frontmatter.title }}

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.

import createClient from "openapi-fetch";
import { createImmutableHook } 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.