Explorar el Código

pass should fetch to useSWRxPageInfo

yohei0125 hace 3 años
padre
commit
a17b71eb02
Se han modificado 1 ficheros con 4 adiciones y 1 borrados
  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) {