From e8b3bb31f0a4eeb4fb7bc6425bb06733b1a9eb8c Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 22 Aug 2026 01:26:43 +0000 Subject: [PATCH] fix(client-react): data-hooks.tsx TSDoc examples read data?.value, not data?.records useQuery and usePagination's @example blocks read data?.value, a key PaginatedResult never declares (packages/client/src/index.ts:310 declares exactly records, total, object, hasMore). Unlike the sibling defect in content/docs/ui/react-pages.mdx (which read?.records failed silently), this one throws: data resolves to a real object, data.value is undefined, and .map on undefined is a TypeError that takes the copied component down. Both sites now read data?.records, matching content/docs/api/client-sdk.mdx. Swept all four @example blocks in the file per the card's rider: useMutation and useInfiniteQuery never referenced .value and needed no change. Fixes #10750 --- .changeset/data-hooks-tsdoc-records-key.md | 15 +++++++++++++++ packages/client-react/src/data-hooks.tsx | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .changeset/data-hooks-tsdoc-records-key.md diff --git a/.changeset/data-hooks-tsdoc-records-key.md b/.changeset/data-hooks-tsdoc-records-key.md new file mode 100644 index 0000000000..7cda522c4a --- /dev/null +++ b/.changeset/data-hooks-tsdoc-records-key.md @@ -0,0 +1,15 @@ +--- +"@objectstack/client-react": patch +--- + +Fix the `useQuery` and `usePagination` TSDoc `@example` blocks in +`packages/client-react/src/data-hooks.tsx`, which read `data?.value` — a key +`PaginatedResult` (declared at `packages/client/src/index.ts:310`) does not +have. `PaginatedResult` declares exactly `records`, `total`, `object`, and +`hasMore`, so `data?.value` was always `undefined`; once the query resolved, +`data` was a real object and `.map` on `undefined` threw, taking the copied +component down. Both examples now read `data?.records`, matching the +hand-written doc that covers the same hooks (`content/docs/api/client-sdk.mdx`). + +Swept all four `@example` blocks in the file: the `useMutation` and +`useInfiniteQuery` examples never referenced `.value` and needed no change. diff --git a/packages/client-react/src/data-hooks.tsx b/packages/client-react/src/data-hooks.tsx index 3a187a9795..050d487d5f 100644 --- a/packages/client-react/src/data-hooks.tsx +++ b/packages/client-react/src/data-hooks.tsx @@ -79,7 +79,7 @@ export interface UseQueryResult { * * return ( *
- * {data?.value.map(task => ( + * {data?.records.map(task => ( *
{task.subject}
* ))} *
@@ -402,7 +402,7 @@ export interface UsePaginationResult extends UseQueryResult { * * return ( *
- * {data?.value.map(task =>
{task.subject}
)} + * {data?.records.map(task =>
{task.subject}
)} * * Page {page} of {totalPages} *