so my app is stuck on the loading not routing to the desired page l need help please
useEffect(() => {
// const handleLoggedIn = async () => {
// const isLoggedIn = await magic.user.isLoggedIn();
// if (isLoggedIn) {
// // route to /
// router.push("/");
// } else {
// // route to /login
// router.push("/login");
// }
// };
// handleLoggedIn();
}, []);
useEffect(() => {
const handleStart = (url) => (url !== router.asPath) && setIsLoading(true);
const handleComplete = (url) => (url === router.asPath) && setIsLoading(false);
router.events.on('routeChangeStart', handleStart)
router.events.on('routeChangeComplete', handleComplete)
router.events.on('routeChangeError', handleComplete)
return () => {
router.events.off('routeChangeStart', handleStart)
router.events.off('routeChangeComplete', handleComplete)
router.events.off('routeChangeError', handleComplete)
};
}, [router]);
return isLoading ? : ;
}
export default MyApp;
so the part that was commented out was suppose to make the routing possible, its stuck on loading screen more of like a loop.
PLEASE HELP
Top comments (0)