use isPending instead of isFetching for pagination guards

isFetching blocks pagination during background refetches of cached data.
isPending correctly targets the case we care about: no real data yet.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Samuel Newman
2026-03-20 13:35:31 +02:00
parent 0b3ebcbbe6
commit b95b435e30
2 changed files with 9 additions and 2 deletions
+8 -2
View File
@@ -363,7 +363,10 @@ export function PostThread({uri}: {uri: string}) {
)
const onStartReached = () => {
if (thread.state.isFetching) return
// Don't paginate until we have real data. We intentionally don't check
// `isFetching` — background refetches shouldn't block pagination when
// we already have real cached data.
if (thread.state.isPending) return
// can be true after `prepareForParamsUpdate` is called
if (deferParents) return
// prevent any state mutations if we know we're done
@@ -375,7 +378,10 @@ export function PostThread({uri}: {uri: string}) {
}
const onEndReached = () => {
if (thread.state.isFetching) return
// Don't paginate until we have real data. We intentionally don't check
// `isFetching` — background refetches shouldn't block pagination when
// we already have real cached data.
if (thread.state.isPending) return
// can be true after `prepareForParamsUpdate` is called
if (deferParents) return
// prevent any state mutations if we know we're done
+1
View File
@@ -286,6 +286,7 @@ export function usePostThread({anchor}: {anchor?: string}) {
/*
* Copy in any query state that is useful
*/
isPending: query.isPending,
isFetching: query.isFetching,
isPlaceholderData: query.isPlaceholderData,
error: query.error,