Explorar el Código

Use useSWRImmutable

Shun Miyazawa hace 1 año
padre
commit
c677155d5f
Se han modificado 1 ficheros con 3 adiciones y 2 borrados
  1. 3 2
      apps/app/src/features/openai/client/stores/ai-assistant.tsx

+ 3 - 2
apps/app/src/features/openai/client/stores/ai-assistant.tsx

@@ -1,7 +1,8 @@
 import { useCallback } from 'react';
 
 import { useSWRStatic } from '@growi/core/dist/swr';
-import useSWR, { type SWRResponse } from 'swr';
+import { type SWRResponse } from 'swr';
+import useSWRImmutable from 'swr/immutable';
 
 import { apiv3Get } from '~/client/util/apiv3-client';
 
@@ -45,7 +46,7 @@ export const useAiAssistantManagementModal = (
 
 
 export const useSWRxAiAssistants = (): SWRResponse<AccessibleAiAssistantsHasId, Error> => {
-  return useSWR<AccessibleAiAssistantsHasId>(
+  return useSWRImmutable<AccessibleAiAssistantsHasId>(
     ['/openai/ai-assistants'],
     ([endpoint]) => apiv3Get(endpoint).then(response => response.data.accessibleAiAssistants),
   );