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
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
This commit is contained in:
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user