Error: Dynamic server usage: searchParams.state
Unanswered
Anhinga posted this in #help-forum
AnhingaOP
I got this error sometimes when Im using a fetch in a server components :
export default async function LaunchpadsPage({
searchParams: { state }
}: LaunchpadsPageProps) {
const launchpads = await getLaunchpads(state as LaunchpadState);
return (
<PageWrapper>
<AllLaunchpadsSection launchpads={launchpads} state={state} />
</PageWrapper>
);
}32 Replies
AnhingaOP
can try adding
export const dynamic = 'force-dynamic'AnhingaOP
its not dangereous ? @joulev
@Anhinga its not dangereous ? <@484037068239142956>
are you using
generateStaticParams or anything that uses the word static?AnhingaOP
Because basically I have a state and each time Im using a router.replace to refecth again the values
src/app/[locale] there it is, this is most likely a static localeAnhingaOP
no that's necessary ?
I have the staticParams for locales
yeah then your pages are set to be static
but this
searchParams usage is trying to make it dynamichence causing the error
sorry, i don't use i18n so don't know how to fix this
AnhingaOP
oh really
good luck
AnhingaOP
are you using translations ?
somehow
no i havent implemented i18n in any appdir apps
AnhingaOP
okay sad, so its like my main layout rendering every pages as static
and I cant use searchParams to render it dynamically ?
yeah that's the cause of the error;
searchParams is trying to render a page dynamically but that page is restricted to static rendering by at least one generateStaticParamsI can remove the static generation ?
a small amount of people is able to help me there that's my biggest problem right now and im stuck since yesterday
i see lots of i18n questions but since i myself havent used i18n in the app directory so can't help; good luck
AnhingaOP
is like removing the generateStaticParams works
from my localelayout
@Anhinga is like removing the generateStaticParams works
oh yeah i think that actually works
do check for the
locale from params inside the layout and throw notFound() if necessaryAnhingaOP
yeah I did