Comments (5)
interesting. so I added another log that just imperatively reads queryClient.isFetching()
right before calling fetchNextPage
, and we can really see that it's already at 1
(which means there is a fetch going on) while the fetchNextPage
variable is still at false
:
invoking fetchNextPage(), isFetching is 0
fetchBranches()
isFetchingNextPage: ❌
invoking fetchNextPage(), isFetching is 1
fetchBranches()
4 isFetchingNextPage: ✅
2 fetched 200 - 300
This could be because we batch updates to observers together to avoid frequent renders, but in this case, where every minimal scroll seems to trigger a re-render, this could interfer.
We allow overriding how we batch things in the latest v5 version with notifyManager.setScheduler
I tried setting it to not batch at all with:
notifyManager.setScheduler((cb) => cb());
and I haven't been able to reproduce the issue since.
You can also try requestAnimationFrame
or queueMicrotask
to see if that yields better results for you over our default settings.
from query.
Would it be possible to apply this setting to just one query
not possible, because it's about batching updates together, and that doesn't happen on a per-query level.
is it safe to use the requestAnimationFrame or queueMicrotask option for the entire project?
absolutely - any batching mechanism is okay. Some might result in more re-renders than others. We might switch default in a future major, but that's not decided.
from query.
I can't reproduce this in the sandbox and your video doesn't play for me ...
from query.
@TkDodo, try opening the video in a different browser. The example is reproducible, but it may require several attempts to see the issue.
from query.
Thanks, @TkDodo. Batching with setTimeout(callback, 0)
as a default setting was the main reason why isFetchingNextPage
wasn't updated in the next render cycle. cb = cb()
works in 100% of cases 🎉, and requestAnimationFrame
and queueMicrotask
also work almost perfectly (I only saw one parallel request among 200 pages).
Would it be possible to apply this setting to just one query, not the entire project? If yes, how can it be done? If no, is it safe to use the requestAnimationFrame
or queueMicrotask
option for the entire project?
P.S. Also, it would be good to mention it here: TanStack Infinite Scroll
from query.
Related Issues (20)
- `useQueries` results are not stable even with memorization attempts HOT 9
- Unable to type the `useMutationState` hook HOT 1
- [svelte-query] derived `$page.params` store will becomes undefined during client side navigation HOT 2
- Homepage is erroring HOT 3
- eslint-plugin-query: exhaustive-deps error not triggered when dependency is nested inside then/catch HOT 1
- Vue.js example in the docs doesn't work HOT 2
- Devtools client prop is not working on Astro
- The object passed to the `queryFn` should be typed as `QueryFunctionContext` when using `useQueries` HOT 3
- Prefetched queries in SvelteKit that uses TRPC are refetched on the client regardless of staleness
- Cancelling query retry on observer unsubscribe inconsistency HOT 2
- useInfiniteQuery causes NotifyEventQueryObserverOptionsUpdated event to be fired without query set
- different behavior without/with developer console HOT 3
- react query 3.39.3 devtools error HOT 1
- Error Boundary Error: A component suspended HOT 1
- The query gets stuck at `fetching` status when re-fetched data has cycles HOT 4
- Devtools + async persistence + custom queryKeyHashFn doesn't work HOT 14
- Solid Query: App crashes when a query in a component is resolved before a query in a context provider HOT 2
- 'PersistQueryClientProvider' refers to a value, but is being used as a type here. Did you mean 'typeof PersistQueryClientProvider' HOT 2
- docs: Wrong URL for Nextjs example HOT 5
- `useQuery` with `initialData` is returning `undefined` data when another query with the same key a no `initialData` is fetching HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from query.