Skip to content

docs(client-react): the useQuery and usePagination TSDoc examples read data?.value, which PaginatedResult does not declare — the copied code throws #10750

Description

@claude

Found while fixing #10469 (the react-pages live-data sample read result.records, a key the objectui adapter never emits). Filing rather than fixing: that card is scoped to content/docs/ui/react-pages.mdx only, and this is a different file in a different package.

The defect

packages/client-react/src/data-hooks.tsx carries two TSDoc @example blocks that read data?.value:

  • :82 — the useQuery example: {data?.value.map(task => (<div key={task.id}>{task.subject}</div>))}
  • :405 — the usePagination example: {data?.value.map(task => <div key={task.id}>{task.subject}</div>)}

Neither hook ever produces a value key.

useQuery declares data as PaginatedResult<T> and assigns it straight from the client (let result: PaginatedResult<T>setData(result)). PaginatedResult is declared at packages/client/src/index.ts:310 and has exactly four members:

exportinterfacePaginatedResult<T=any>{/** Spec-compliant: array of matching records */records: T[];total?: number;object?: string;hasMore?: boolean;}

usePagination inherits the same object — it calls useQuery internally and returns { ...queryResult, page, totalPages, … }, and reads the result itself as queryResult.data?.total.

So data?.value is undefined on every call.

Why this is worse than the sibling defect

The content/docs/ui/react-pages.mdx instance failed silently — the read missed and the list rendered empty. This one throws. ?. short-circuits only when data is nullish; once the query resolves, data is a real object, data.value is undefined, and .map on undefined is a TypeError that takes the component down. A reader copying either example gets a crash on first successful load.

The correct spelling for both is data?.records. The hand-written doc that covers the same hooks already gets it right — content/docs/api/client-sdk.mdx:659 reads data?.records.map(…) — so the two published surfaces for one contract currently disagree, and the wrong one is the one shipped inside the package's own source.

Suggested fix

Change data?.value to data?.records at both sites. Worth checking whether useInfiniteQuery and any other @example in that file read the same key before landing it.

Note on scope

check:doc-formula-expressions does read spec TSDoc @examples, but only for formula expressions, and packages/client-react is not in its surface — nothing currently type-checks these blocks, which is why they rotted unobserved.


Generated by Claude Code


Generated by Claude Code

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions