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

Do not fetch if pageId is undefined

Shun Miyazawa 3 лет назад
Родитель
Сommit
c66e6c3fb8
1 измененных файлов с 1 добавлено и 2 удалено
  1. 1 2
      packages/app/src/stores/page.tsx

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

@@ -81,9 +81,8 @@ export const useSWRxCurrentPage = (
 
 
 export const useSWRxTagsInfo = (pageId: Nullable<string>): SWRResponse<IPageTagsInfo | undefined, Error> => {
-
   const endpoint = `/pages.getPageTag?pageId=${pageId}`;
-  const key = [endpoint, pageId];
+  const key = pageId != null ? [endpoint, pageId] : null;
 
   const fetcher = async(endpoint: string, pageId: Nullable<string>) => {
     let tags: string[] = [];