Can someone explain how data flow here
Answered
Raspberry Horntail posted this in #help-forum
Raspberry HorntailOP
i am currently at chapter 11 https://nextjs.org/learn/dashboard-app/adding-search-and-pagination
can someone explain from where searchParams props from Page comes from to this component
import Pagination from '@/app/ui/invoices/pagination';
import Search from '@/app/ui/search';
import Table from '@/app/ui/invoices/table';
import { CreateInvoice } from '@/app/ui/invoices/buttons';
import { lusitana } from '@/app/ui/fonts';
import { Suspense } from 'react';
import { InvoicesTableSkeleton } from '@/app/ui/skeletons';
export default async function Page({
searchParams,
}: {
searchParams?: {
query?: string;
page?: string;
};
}) {
const query = searchParams?.query || '';
const currentPage = Number(searchParams?.page) || 1;
return (
<div className="w-full">
<div className="flex w-full items-center justify-between">
<h1 className={`${lusitana.className} text-2xl`}>Invoices</h1>
</div>
<div className="mt-4 flex items-center justify-between gap-2 md:mt-8">
<Search placeholder="Search invoices..." />
<CreateInvoice />
</div>
<Suspense key={query + currentPage} fallback={<InvoicesTableSkeleton />}>
<Table query={query} currentPage={currentPage} />
</Suspense>
<div className="mt-5 flex w-full justify-center">
{/* <Pagination totalPages={totalPages} /> */}
</div>
</div>
);
}can someone explain from where searchParams props from Page comes from to this component
<Suspense key={query + currentPage} fallback={<InvoicesTableSkeleton />}>
<Table query={query} currentPage={currentPage} />
</Suspense>Answered by B33fb0n3
it comes from the page. The page.tsx receives the searchParams from nextjs itself
5 Replies
@B33fb0n3 it comes from the page. The page.tsx receives the searchParams from nextjs itself
Raspberry HorntailOP
ahh thanks