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

supress unnecessary API requests when using for mutation purposes

Yuki Takei 2 лет назад
Родитель
Сommit
65499d0f4b
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      apps/app/src/stores/bookmark.ts

+ 3 - 1
apps/app/src/stores/bookmark.ts

@@ -17,10 +17,12 @@ export const useSWRBookmarkInfo = (pageId: string | null | undefined): SWRRespon
         pageId: response.data.pageId,
         pageId: response.data.pageId,
       };
       };
     }),
     }),
+    // supress unnecessary API requests when using for mutation purposes
+    { revalidateOnMount: false },
   );
   );
 };
 };
 
 
-export const useSWRxUserBookmarks = (userId?: string): SWRResponse<IPageHasId[], Error> => {
+export const useSWRxUserBookmarks = (userId: string | null): SWRResponse<IPageHasId[], Error> => {
   return useSWRImmutable(
   return useSWRImmutable(
     userId != null ? `/bookmarks/${userId}` : null,
     userId != null ? `/bookmarks/${userId}` : null,
     endpoint => apiv3Get(endpoint).then((response) => {
     endpoint => apiv3Get(endpoint).then((response) => {