fix: route redirection issue
This commit is contained in:
parent
dec1fd29f5
commit
9a8a7ee978
|
@ -1,24 +1,19 @@
|
||||||
import { useGo, useIsAuthenticated } from "@refinedev/core";
|
import { useGo, useIsAuthenticated } from "@refinedev/core";
|
||||||
import {useEffect} from "react";
|
|
||||||
|
|
||||||
export default function Index() {
|
export default function Index() {
|
||||||
const { isLoading, data } = useIsAuthenticated();
|
const { isLoading, data } = useIsAuthenticated();
|
||||||
|
|
||||||
const go = useGo();
|
const go = useGo();
|
||||||
|
|
||||||
useEffect(() => {
|
if (isLoading) {
|
||||||
if (!isLoading) {
|
return <>Checking Login Status</>;
|
||||||
|
}
|
||||||
|
|
||||||
if (data?.authenticated) {
|
if (data?.authenticated) {
|
||||||
go({ to: "/dashboard", type: "replace" });
|
go({ to: "/dashboard", type: "replace" });
|
||||||
} else {
|
} else {
|
||||||
go({ to: "/login", type: "replace" });
|
go({ to: "/login", type: "replace" });
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, [isLoading, data]);
|
|
||||||
|
|
||||||
if (isLoading) {
|
return <>Redirecting</>;
|
||||||
return <>Checking Login Status</> || null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (<>Redirecting</>) || null;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue