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

pass should fetch to useSWRxPageInfo

yohei0125 3 лет назад
Родитель
Сommit
a17b71eb02
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      packages/app/src/components/PageAlert/PageStaleAlert.tsx

+ 4 - 1
packages/app/src/components/PageAlert/PageStaleAlert.tsx

@@ -6,7 +6,10 @@ export const PageStaleAlert = ():JSX.Element => {
   const { t } = useTranslation()
   const { data: isEnabledStaleNotification } = useIsEnabledStaleNotification();
   const { data: pageData } = useSWRxCurrentPage();
-  const { data: pageInfo } = useSWRxPageInfo(pageData?._id);
+
+  const shouldfetch = isEnabledStaleNotification;
+  const { data: pageInfo } = useSWRxPageInfo(shouldfetch ? pageData?._id : null);
+
   const contentAge = pageInfo?.contentAge;
 
   if (!isEnabledStaleNotification) {