Jelajahi Sumber

assign data in variables before if condition

yohei0125 4 tahun lalu
induk
melakukan
1ccfd53778
1 mengubah file dengan 5 tambahan dan 1 penghapusan
  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]);