Ver Fonte

assign data in variables before if condition

yohei0125 há 4 anos atrás
pai
commit
1ccfd53778
1 ficheiros alterados com 5 adições e 1 exclusões
  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
   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);
     }
   }, [pageId, path, notFoundTargetPathOrId]);