From 9a8a7ee97817621f7a4378b25ef9c8b048b81f99 Mon Sep 17 00:00:00 2001 From: Juan Di Toro Date: Tue, 19 Mar 2024 23:41:45 +0100 Subject: [PATCH] fix: route redirection issue --- app/routes/_index.tsx | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/app/routes/_index.tsx b/app/routes/_index.tsx index 666f9ca..150bb68 100644 --- a/app/routes/_index.tsx +++ b/app/routes/_index.tsx @@ -1,24 +1,19 @@ -import {useGo, useIsAuthenticated} from "@refinedev/core"; -import {useEffect} from "react"; +import { useGo, useIsAuthenticated } from "@refinedev/core"; export default function Index() { - const {isLoading, data} = useIsAuthenticated(); + const { isLoading, data } = useIsAuthenticated(); - const go = useGo(); + const go = useGo(); - useEffect(() => { - if (!isLoading) { - if (data?.authenticated) { - go({to: "/dashboard", type: "replace"}); - } else { - go({to: "/login", type: "replace"}); - } - } - }, [isLoading, data]); + if (isLoading) { + return <>Checking Login Status; + } - if (isLoading) { - return <>Checking Login Status || null; - } + if (data?.authenticated) { + go({ to: "/dashboard", type: "replace" }); + } else { + go({ to: "/login", type: "replace" }); + } - return (<>Redirecting) || null; + return <>Redirecting; }