🔀 refactor(routes.tsx): use useEffect hook to redirect from root to /flows for better code organization and readability
This commit is contained in:
parent
225d6da419
commit
0c882cec44
1 changed files with 7 additions and 6 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { useEffect } from "react";
|
||||||
import { Route, Routes, useNavigate } from "react-router-dom";
|
import { Route, Routes, useNavigate } from "react-router-dom";
|
||||||
import { ProtectedAdminRoute } from "./components/authAdminGuard";
|
import { ProtectedAdminRoute } from "./components/authAdminGuard";
|
||||||
import { ProtectedRoute } from "./components/authGuard";
|
import { ProtectedRoute } from "./components/authGuard";
|
||||||
|
|
@ -22,12 +23,12 @@ import SignUp from "./pages/signUpPage";
|
||||||
|
|
||||||
const Router = () => {
|
const Router = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
useEffect(() => {
|
||||||
// Redirect from root to /flows
|
// Redirect from root to /flows
|
||||||
if (window.location.pathname === "/") {
|
if (window.location.pathname === "/") {
|
||||||
navigate("/flows");
|
navigate("/flows");
|
||||||
}
|
}
|
||||||
|
}, [navigate]);
|
||||||
return (
|
return (
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route
|
<Route
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue