From 0c882cec44ff550aa826562153f28679d95c9448 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 7 Nov 2023 21:00:48 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=80=20refactor(routes.tsx):=20use=20us?= =?UTF-8?q?eEffect=20hook=20to=20redirect=20from=20root=20to=20/flows=20fo?= =?UTF-8?q?r=20better=20code=20organization=20and=20readability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/routes.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/frontend/src/routes.tsx b/src/frontend/src/routes.tsx index ff45d8e6c..73aad35f8 100644 --- a/src/frontend/src/routes.tsx +++ b/src/frontend/src/routes.tsx @@ -1,3 +1,4 @@ +import { useEffect } from "react"; import { Route, Routes, useNavigate } from "react-router-dom"; import { ProtectedAdminRoute } from "./components/authAdminGuard"; import { ProtectedRoute } from "./components/authGuard"; @@ -22,12 +23,12 @@ import SignUp from "./pages/signUpPage"; const Router = () => { const navigate = useNavigate(); - - // Redirect from root to /flows - if (window.location.pathname === "/") { - navigate("/flows"); - } - + useEffect(() => { + // Redirect from root to /flows + if (window.location.pathname === "/") { + navigate("/flows"); + } + }, [navigate]); return (