Mental Model
If you remember one thing, it is this: same data !== same user view. Remote queries can resolve to the same rows, but page, page size, and total metadata still belong to the query context.
Shared data
Rows are treated as a read-only shared resource and can be aliased when the payload is deeply equal.
Isolated pagination
Each query stores its own page, pageSize, totalItems, and totalPages.
Stable UX
Switching between remote queries restores the correct page state instead of deriving it from whichever dataset was cached first.
Guardrails
- Do not share pagination across query keys.
- Do not drop pagination just because the row payload was reused.
- Do not derive user view state from the shared dataset cache.
- Always preserve per-query page navigation and page-size changes.
Implementation Pattern
Dog Table uses a split cache in src/data/RemoteAdapter.js: one store for canonical datasets and one store for query metadata.
cache.data[dataHash] = dataset
cache.query[queryKey] = {
dataRef: dataHash,
pagination: {
page,
pageSize,
totalItems,
totalPages
}
}
The logical queryKey is built from remote URL + search + sort state, excluding page and page size. That makes it possible to reuse rows while still restoring the last known pagination for that query context.
Expected Behavior
Search transitions
A brand-new remote search starts from page 1. Returning to a previous search restores that query’s stored pagination.
Sort transitions
Sort order changes can point to the same dataset, but each sort context still keeps its own pagination metadata.
Memory efficiency
Deeply equal row sets are stored once and referenced by multiple remote request contexts.
API Impact
No public constructor or method names changed. The feature is internal, but it affects how remote state behaves:
setSearch(query)restores cached pagination for previously seen remote queries.setSort(key, direction)keeps pagination independent per remote query context.setPage(pageNumber)andsetPageSize(pageSize)persist pagination into the active query cache.