Open this example in the interactive library
Source code
// app/billing/page.tsx
export default async function InvoiceRangeBands({
searchParams,
}: {
searchParams: Promise<Record<string, string | string[] | undefined>>;
}) {
const invoices = [
{ id: "A", cents: 3200, paid: true, due: "2028-01-10" },
{ id: "B", cents: 7900, paid: false, due: "2028-02-15" },
{ id: "C", cents: 4600, paid: false, due: "2028-03-20" },
];
const { low, high } = await searchParams;
return (
<ol>
{invoices
.filter(
(i) =>
i.cents >= Number(low ?? 0) * 100 && i.cents <= Number(high ?? 1000) * 100,
)
.map((i) => (
<li key={i.id}>
Invoice {i.id} · {(i.cents / 100).toFixed(2)}
</li>
))}
</ol>
);
}
