Просмотр исходного кода

assign data in variables before if condition

yohei0125 3 лет назад
Родитель
Сommit
1ccfd53778
1 измененных файлов с 5 добавлено и 1 удалено
  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]);