fix(build): read URL params via window in guards (avoid useSearchParams prerender error)
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled

This commit is contained in:
belisards
2026-05-03 17:02:45 -03:00
parent 2418ab64cc
commit d33feced1d
3 changed files with 8 additions and 14 deletions

View File

@@ -2,18 +2,18 @@
import { useEffect, useState } from 'react';
import Link from 'next/link';
import { useRouter, useSearchParams } from 'next/navigation';
import { useRouter } from 'next/navigation';
import { authApi, wishlistsApi, type Wishlist } from '@/lib/api';
export default function HomePage() {
const router = useRouter();
const params = useSearchParams();
const [state, setState] = useState<'checking' | 'guest' | 'none'>('checking');
const [wishlists, setWishlists] = useState<Wishlist[]>([]);
useEffect(() => {
let cancelled = false;
(async () => {
const params = new URL(window.location.href).searchParams;
const adm = params.get('adm');
const usr = params.get('usr');
try {
@@ -48,7 +48,7 @@ export default function HomePage() {
}
})();
return () => { cancelled = true; };
}, [params, router]);
}, [router]);
if (state === 'checking') {
return <div className="min-h-screen flex items-center justify-center text-gray-500">Carregando</div>;