Skip to content
Chapter 60Lesson 5

Quiz - URL-state list views

Quiz progress

0 / 0

You’re reviewing a teammate’s invoices list. They demo it: clicking a status filter visibly narrows the table, sorting flips the order, paging swaps the rows — every interaction works. But you notice the address bar never changes. What’s the verdict?

Ship it — the controls all produce the correct result, which is what the user cares about.
Reject it — if a click changes the result but not the URL, the share-and-refresh contract is broken: a refresh or shared link won’t reproduce the view.
Ship it, but add a useEffect that writes the current filter/sort/page into the URL after each render so links still work.

In the list view, a user changes a filter chip. Which navigation call belongs in the control, and why?

router.push('?status=overdue', { scroll: false }) — every state change is a distinct view the user should be able to step back to.
router.replace('?status=overdue', { scroll: false }) — reconfiguring the current view should swap the history entry in place, so the back button leaves the list instead of rewinding chips one at a time.
router.push('/invoices/overdue') — filter changes are genuine navigation to a new page.

The sort parameter could be typed as parseAsString (accept any column name) or parseAsStringEnum([...]) (a closed list of columns). The course insists on the enum. Which problems does the enum prevent that a free string would allow? Select all that apply.

A hand-typed ?sort=passwordHash reaching the query and ordering rows by a column that should never be exposed — the sort value is the column, which the driver can’t parameterize away.
A sort on an unindexed column forcing the database to load and sort the whole result set in memory — fine on 100 rows, a timeout on 50,000.
The URL growing too long because free-string sort values aren’t stripped when they equal the default.

In the search box, you use both React’s useDeferredValue and nuqs’s limitUrlUpdates: debounce(300). A reviewer says one is redundant — pick one. Are they right?

Yes — both delay the search, so useDeferredValue alone (or the debounce alone) covers it; keeping both is belt-and-suspenders.
No — they bound different things: useDeferredValue is render priority on this device (adaptive, coalesces keystrokes), while debounce keeps partial input from writing the URL and hitting the server — a threshold meaningful outside the browser.
No — useDeferredValue controls the URL write and debounce controls the input’s repaint, so removing either breaks a different half of the box.

A search write needs shallow: false. What does dropping that option do?

The URL still updates on the client, but the write never notifies the server, so the Server Component never re-renders and the list never re-queries.
Every keystroke pushes a new browser-history entry, so the back button rewinds the search one letter at a time.
The input’s value desyncs from the URL, so the box stops reflecting what the user typed.

Cursor pagination is the chapter’s default. When is reaching for offset (?page=N) instead the right call?

Whenever the product wants a numbered “page 3 of 7” pager, since cursors can’t show a total.
Only when all three hold at once: the set is small and known-bounded, the offset stays shallow, and the product genuinely needs jump-to-page-N random access.
For any list under heavy write traffic, since offset re-counts rows on every request and stays current.

A coworker pastes you a cursor-paginated link. By the time you open it, two new invoices have been created above the encoded position. You see rows your coworker never saw, and they file “the pagination link is broken.” What’s the correct response?

It’s a bug — a shared URL must reproduce the exact rows the sender was looking at, so the cursor should encode a frozen snapshot.
It’s correct behavior — a cursor URL guarantees the position (“the rows after this point in the current data”), not a snapshot of the exact rows the sender saw.
It’s a bug caused by skipping the cursor reset — clearing the cursor on share would have shown the same rows.

Quiz complete

Score by topic