Просмотр исходного кода

fix SWR settings for searching

Yuki Takei 2 лет назад
Родитель
Сommit
51114e5252
1 измененных файлов с 6 добавлено и 3 удалено
  1. 6 3
      apps/app/src/stores/search.tsx

+ 6 - 3
apps/app/src/stores/search.tsx

@@ -1,5 +1,4 @@
-import { mutate, SWRResponse } from 'swr';
-import useSWRImmutable from 'swr/immutable';
+import useSWR, { mutate, SWRResponse } from 'swr';
 
 
 import { apiGet } from '~/client/util/apiv1-client';
 import { apiGet } from '~/client/util/apiv1-client';
 import { IFormattedSearchResult, SORT_AXIS, SORT_ORDER } from '~/interfaces/search';
 import { IFormattedSearchResult, SORT_AXIS, SORT_ORDER } from '~/interfaces/search';
@@ -67,7 +66,7 @@ export const useSWRxSearch = (
 
 
   const isKeywordValid = keyword != null && keyword.length > 0;
   const isKeywordValid = keyword != null && keyword.length > 0;
 
 
-  const swrResult = useSWRImmutable(
+  const swrResult = useSWR(
     isKeywordValid ? ['/search', keyword, fixedConfigurations] : null,
     isKeywordValid ? ['/search', keyword, fixedConfigurations] : null,
     ([endpoint, , fixedConfigurations]) => {
     ([endpoint, , fixedConfigurations]) => {
       const {
       const {
@@ -86,6 +85,10 @@ export const useSWRxSearch = (
       // eslint-disable-next-line @typescript-eslint/no-explicit-any
       // eslint-disable-next-line @typescript-eslint/no-explicit-any
       ).then(result => result as IFormattedSearchResult);
       ).then(result => result as IFormattedSearchResult);
     },
     },
+    {
+      revalidateOnFocus: false,
+      revalidateOnReconnect: false,
+    },
   );
   );
 
 
   return {
   return {