Open this example in the interactive library
Source code
// app/trains/page.tsx
export default function DelayedDeparturesBoard() {
const trains = [
{ id: "A1", to: "Union", min: 510, track: 2, delay: 4 },
{ id: "B4", to: "West", min: 560, track: 1, delay: 0 },
{ id: "A2", to: "Union", min: 600, track: 2, delay: 12 },
];
return (
<table>
<caption>Delays</caption>
<tbody>
{trains
.filter((t) => t.delay > 0)
.sort((a, b) => b.delay - a.delay)
.map((t) => (
<tr key={t.id}>
<th>{t.id}</th>
<td>+{t.delay} min</td>
</tr>
))}
</tbody>
</table>
);
}
