fix: route redirection issue
This commit is contained in:
parent
dec1fd29f5
commit
9a8a7ee978
|
@ -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();
|
||||
|
||||
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</> || null;
|
||||
return <>Checking Login Status</>;
|
||||
}
|
||||
|
||||
return (<>Redirecting</>) || null;
|
||||
if (data?.authenticated) {
|
||||
go({ to: "/dashboard", type: "replace" });
|
||||
} else {
|
||||
go({ to: "/login", type: "replace" });
|
||||
}
|
||||
|
||||
return <>Redirecting</>;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue