Преглед изворни кода

supress unnecessary API requests when using for mutation purposes

Yuki Takei пре 2 година
родитељ
комит
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,
       };
     }),
+    // 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(
     userId != null ? `/bookmarks/${userId}` : null,
     endpoint => apiv3Get(endpoint).then((response) => {