Module 40: Dashboard Project

Lesson 4 of 5 · 15–25 minutes

Integrating the API

🏠The everyday picture

The front office and the back office agree a set of forms for passing work between them. If either side changes a form without telling the other, work gets lost.

📘What it really is

useQuery({
  queryKey: ["enquiries", { status, assignee, q, sort, page }],
  queryFn: () => listEnquiries({ status, assignee, q, sort, page }),
  placeholderData: keepPreviousData,
});

keepPreviousData keeps the current page visible while the next one loads, so the table doesn't flash empty.

🖱️Try it

Connect the table to the API with filters, sorting and paging as query parameters. Implement the detail page with status changes, assignment and notes as mutations. Tick off each requirement in REQUIREMENTS.md as it works.

✅Quick check

Why include the filters in the query key?

Show the answer

Each combination is cached separately, and changing a filter fetches the right data.

What does keepPreviousData do for a paginated table?

Show the answer

Keeps the current page showing while the next loads, avoiding an empty flash.

← PreviousTables, filters and sorting
ProLearners Assist