Skip to content

Commit cc58b7f

Browse files
committed
2 parents 7e29579 + 4fc9e74 commit cc58b7f

File tree

5 files changed

+47
-5
lines changed

5 files changed

+47
-5
lines changed

docs/src/pages/guides/initial-query-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ By default, `initialData` is treated as totally fresh, as if it were just fetche
5252
}
5353
```
5454

55-
- So what if your `initialData` isn't totally fresh? That leaves us with the last configuration that is actually the most accurate and uses an option called `initialDataUpdatedAt`. This options allows you to pass a numeric unix timestamp of when the initialData itself was last updated.
55+
- So what if your `initialData` isn't totally fresh? That leaves us with the last configuration that is actually the most accurate and uses an option called `initialDataUpdatedAt`. This options allows you to pass a numeric JS timestamp in milliseconds of when the initialData itself was last updated, e.g. what `Date.now()` provides. Take note that if you have a unix timestamp, you'll need to convert it to a JS timestamp by multiplying it by `1000`.
5656
```js
5757
function Todos() {
5858
// Show initialTodos immeidately, but won't refetch until another interaction event is encountered after 1000 ms

docs/src/pages/guides/query-invalidation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ When a query is invalidated with `invalidateQueries`, two things happen:
2121

2222
## Query Matching with `invalidateQueries`
2323

24-
When using APIs like `invalidateQueries` and `removeQueries` (and others that support partial query matching), you can match multiple queries by their prefix, or get really specific and match an exact query. For informationo on the types of filters, you can use, please see [Query Filters](./query-filters).
24+
When using APIs like `invalidateQueries` and `removeQueries` (and others that support partial query matching), you can match multiple queries by their prefix, or get really specific and match an exact query. For information on the types of filters you can use, please see [Query Filters](./query-filters).
2525

2626
In this example, we can use the `todos` prefix to invalidate any queries that start with `todos` in their query key:
2727

src/core/infiniteQueryObserver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ export class InfiniteQueryObserver<
107107
...result,
108108
fetchNextPage: this.fetchNextPage,
109109
fetchPreviousPage: this.fetchPreviousPage,
110-
hasNextPage: hasNextPage(this.options, result.data?.pages),
111-
hasPreviousPage: hasPreviousPage(this.options, result.data?.pages),
110+
hasNextPage: hasNextPage(this.options, state.data?.pages),
111+
hasPreviousPage: hasPreviousPage(this.options, state.data?.pages),
112112
isFetchingNextPage:
113113
state.isFetching && state.fetchMeta?.fetchMore?.direction === 'forward',
114114
isFetchingPreviousPage:

src/devtools/devtools.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ export function ReactQueryDevtools({
147147

148148
const run = () => {
149149
const containerHeight = panelRef.current?.getBoundingClientRect().height
150-
console.log(containerHeight)
151150
rootRef.current.parentElement.style.paddingBottom = `${containerHeight}px`
152151
}
153152

src/react/tests/useInfiniteQuery.test.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,49 @@ describe('useInfiniteQuery', () => {
969969
})
970970
})
971971

972+
it('should not use selected data when computing hasNextPage', async () => {
973+
const key = queryKey()
974+
const states: UseInfiniteQueryResult<string>[] = []
975+
976+
function Page() {
977+
const state = useInfiniteQuery(
978+
key,
979+
({ pageParam = 1 }) => Number(pageParam),
980+
{
981+
getNextPageParam: lastPage => (lastPage === 1 ? 2 : false),
982+
select: data => ({
983+
pages: data.pages.map(x => x.toString()),
984+
pageParams: data.pageParams,
985+
}),
986+
}
987+
)
988+
989+
states.push(state)
990+
991+
return null
992+
}
993+
994+
renderWithClient(queryClient, <Page />)
995+
996+
await sleep(100)
997+
998+
expect(states.length).toBe(2)
999+
expect(states[0]).toMatchObject({
1000+
data: undefined,
1001+
hasNextPage: undefined,
1002+
isFetching: true,
1003+
isFetchingNextPage: false,
1004+
isSuccess: false,
1005+
})
1006+
expect(states[1]).toMatchObject({
1007+
data: { pages: ['1'] },
1008+
hasNextPage: true,
1009+
isFetching: false,
1010+
isFetchingNextPage: false,
1011+
isSuccess: true,
1012+
})
1013+
})
1014+
9721015
it('should build fresh cursors on refetch', async () => {
9731016
const key = queryKey()
9741017

0 commit comments

Comments
 (0)