chore: wrap router.replace in useEffect

This commit is contained in:
ValdiANS
2025-12-10 17:31:21 +07:00
parent 3826b8ea53
commit 4f595c7cad
+6 -3
View File
@@ -1,5 +1,6 @@
'use client'; 'use client';
import { useEffect } from 'react';
import { usePathname, useRouter } from 'next/navigation'; import { usePathname, useRouter } from 'next/navigation';
import { useAuth } from '@/services/hooks/useAuth'; import { useAuth } from '@/services/hooks/useAuth';
import { redirectToSSO } from '@/lib/auth-helper'; import { redirectToSSO } from '@/lib/auth-helper';
@@ -10,9 +11,11 @@ export default function Home() {
const router = useRouter(); const router = useRouter();
const pathname = usePathname(); const pathname = usePathname();
if (pathname === '/') { useEffect(() => {
router.replace('/dashboard'); if (pathname === '/') {
} router.replace('/dashboard');
}
}, [pathname]);
if (isLoadingUser) { if (isLoadingUser) {
return ( return (