فهرست منبع

fix useSWRxPageInfo

Yuki Takei 4 سال پیش
والد
کامیت
88c8736572
1فایلهای تغییر یافته به همراه4 افزوده شده و 1 حذف شده
  1. 4 1
      packages/app/src/stores/page.tsx

+ 4 - 1
packages/app/src/stores/page.tsx

@@ -82,8 +82,11 @@ export const useSWRxPageInfo = (
     shareLinkId?: string | null,
     shareLinkId?: string | null,
 ): SWRResponse<IPageInfo | IPageInfoForOperation, Error> => {
 ): SWRResponse<IPageInfo | IPageInfoForOperation, Error> => {
 
 
+  // assign null if shareLinkId is undefined in order to identify SWR key only by pageId
+  const fixedShareLinkId = shareLinkId ?? null;
+
   return useSWRImmutable(
   return useSWRImmutable(
-    pageId != null ? ['/page/info', pageId, shareLinkId] : null,
+    pageId != null ? ['/page/info', pageId, fixedShareLinkId] : null,
     (endpoint, pageId, shareLinkId) => apiv3Get(endpoint, { pageId, shareLinkId }).then(response => response.data),
     (endpoint, pageId, shareLinkId) => apiv3Get(endpoint, { pageId, shareLinkId }).then(response => response.data),
   );
   );
 };
 };