Chapter 11. Adding Search and Pagination
검색과 페이지네이션 추가
시작 코드
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 { InvoicesTableSkeleton } from '@/app/ui/skeletons';
import { Suspense } from 'react';
export default async function Page() {
return (
<div className="w-full">
<div className="flex w-full items-center justify-between">
<h1 className={`${lusitana.className} text-2xl`}>송장</h1>
</div>
<div className="mt-4 flex items-center justify-between gap-2 md:mt-8">
<Search placeholder="송장 검색..." />
<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>
);
}왜 URL 검색 매개변수를 사용할까요?
검색 기능 추가하기
1. 사용자 입력 캡처하기
2. URL 검색 매개변수로 URL 업데이트하기
3. URL과 입력을 동기화하기
4. 테이블 업데이트하기
Best practice: 디바운싱
페이지네이션 추가
요약
Last updated
Was this helpful?