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} *