소스 검색

add fallbackdata

Yuken Tezuka 3 년 전
부모
커밋
a917a6b3b4
1개의 변경된 파일3개의 추가작업 그리고 2개의 파일을 삭제
  1. 3 2
      packages/app/src/stores/page.tsx

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

@@ -179,6 +179,8 @@ export const useCurrentPagePath = (): SWRResponse<string | undefined, Error> =>
   const { data: currentPage } = useSWRxCurrentPage();
   const { data: currentPathname } = useCurrentPathname();
 
+  const fallbackData = (currentPathname != null && !_isPermalink(currentPathname)) ? currentPathname : undefined;
+
   return useSWRImmutable(
     ['currentPagePath', currentPage?.path, currentPathname],
     (key: Key, pagePath: string|undefined, pathname: string|undefined) => {
@@ -190,8 +192,7 @@ export const useCurrentPagePath = (): SWRResponse<string | undefined, Error> =>
       }
       return undefined;
     },
-    // TODO: set fallbackData
-    // { fallbackData:  }
+    { fallbackData },
   );
 };