Procházet zdrojové kódy

assign data in variables before if condition

yohei0125 před 3 roky
rodič
revize
1ccfd53778
1 změnil soubory, kde provedl 5 přidání a 1 odebrání
  1. 5 1
      packages/app/src/components/NotFoundPage.tsx

+ 5 - 1
packages/app/src/components/NotFoundPage.tsx

@@ -27,7 +27,11 @@ const NotFoundPage = (): JSX.Element => {
 
 
   // replace url in address bar with path when accessing empty page by permalink
   // replace url in address bar with path when accessing empty page by permalink
   useEffect(() => {
   useEffect(() => {
-    if (pageId != null && path != null && !notFoundTargetPathOrId?.includes('/')) {
+    const isEmptyPage = pageId != null;
+    const isPathExist = path != null;
+    const isPathLink = notFoundTargetPathOrId?.includes('/');
+
+    if (isEmptyPage && isPathExist && !isPathLink) {
       replaceURLHistory(path);
       replaceURLHistory(path);
     }
     }
   }, [pageId, path, notFoundTargetPathOrId]);
   }, [pageId, path, notFoundTargetPathOrId]);