Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changeset/data-hooks-tsdoc-records-key.md
Original file line numberDiff line numberDiff line change
@@ -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.
4 changes: 2 additions & 2 deletions packages/client-react/src/data-hooks.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -79,7 +79,7 @@ export interface UseQueryResult<T = any> {
*
* return (
* <div>
* {data?.value.map(task => (
* {data?.records.map(task => (
* <div key={task.id}>{task.subject}</div>
* ))}
* </div>
Expand DownExpand Up@@ -402,7 +402,7 @@ export interface UsePaginationResult<T = any> extends UseQueryResult<T> {
*
* return (
* <div>
* {data?.value.map(task => <div key={task.id}>{task.subject}</div>)}
* {data?.records.map(task => <div key={task.id}>{task.subject}</div>)}
* <button onClick={previousPage} disabled={!hasPreviousPage}>Previous</button>
* <span>Page {page} of {totalPages}</span>
* <button onClick={nextPage} disabled={!hasNextPage}>Next</button>
Expand Down
Loading