Next.js Discord

Discord Forum

Prevent Server Action from running for one query param and not for the other

Unanswered
English Lop posted this in #help-forum
Open in Discord
English LopOP
const Page = async ({searchParams}: {
    searchParams: {
        type: string;
    };
}) => {
    const type = searchParams?.type || "normal";

    const responseData = await fetchData(type);

    return (
        <>
            <section className="container flex flex-col">
                <TypeSelect/>
                <PokeSearch/>
            </section>
            <section className="container">
                <Suspense key={type} fallback={<Loader/>}>
                    <PokeGrid responseData={responseData}/>
                </Suspense>
            </section>
        </>
    );
}


I want this to be recalled if type has changed but not if search has changed which is also a query param used in PokeGrid

0 Replies