|
|
@@ -1,24 +1,24 @@
|
|
|
-import assert from 'assert';
|
|
|
-
|
|
|
import {
|
|
|
Key, SWRConfiguration, SWRResponse, useSWRConfig,
|
|
|
} from 'swr';
|
|
|
import useSWRImmutable from 'swr/immutable';
|
|
|
|
|
|
|
|
|
-export function useStaticSWR<Data, Error>(key: Key): SWRResponse<Data, Error>;
|
|
|
-export function useStaticSWR<Data, Error>(key: Key, data: Data | undefined): SWRResponse<Data, Error>;
|
|
|
-export function useStaticSWR<Data, Error>(key: Key, data: Data | undefined,
|
|
|
+export function useSWRStatic<Data, Error>(key: Key): SWRResponse<Data, Error>;
|
|
|
+export function useSWRStatic<Data, Error>(key: Key, data: Data | undefined): SWRResponse<Data, Error>;
|
|
|
+export function useSWRStatic<Data, Error>(key: Key, data: Data | undefined,
|
|
|
configuration: SWRConfiguration<Data, Error> | undefined): SWRResponse<Data, Error>;
|
|
|
|
|
|
-export function useStaticSWR<Data, Error>(
|
|
|
+export function useSWRStatic<Data, Error>(
|
|
|
...args: readonly [Key]
|
|
|
| readonly [Key, Data | undefined]
|
|
|
| readonly [Key, Data | undefined, SWRConfiguration<Data, Error> | undefined]
|
|
|
): SWRResponse<Data, Error> {
|
|
|
const [key, data, configuration] = args;
|
|
|
|
|
|
- assert.notStrictEqual(configuration?.fetcher, null, 'useStaticSWR does not support \'configuration.fetcher\'');
|
|
|
+ if (configuration?.fetcher != null) {
|
|
|
+ throw new Error("useSWRStatic does not support 'configuration.fetcher'");
|
|
|
+ }
|
|
|
|
|
|
const { cache } = useSWRConfig();
|
|
|
const swrResponse = useSWRImmutable(key, null, {
|