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:
@@ -363,7 +363,10 @@ export function PostThread({uri}: {uri: string}) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const onStartReached = () => {
|
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
|
// can be true after `prepareForParamsUpdate` is called
|
||||||
if (deferParents) return
|
if (deferParents) return
|
||||||
// prevent any state mutations if we know we're done
|
// prevent any state mutations if we know we're done
|
||||||
@@ -375,7 +378,10 @@ export function PostThread({uri}: {uri: string}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onEndReached = () => {
|
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
|
// can be true after `prepareForParamsUpdate` is called
|
||||||
if (deferParents) return
|
if (deferParents) return
|
||||||
// prevent any state mutations if we know we're done
|
// prevent any state mutations if we know we're done
|
||||||
|
|||||||
@@ -286,6 +286,7 @@ export function usePostThread({anchor}: {anchor?: string}) {
|
|||||||
/*
|
/*
|
||||||
* Copy in any query state that is useful
|
* Copy in any query state that is useful
|
||||||
*/
|
*/
|
||||||
|
isPending: query.isPending,
|
||||||
isFetching: query.isFetching,
|
isFetching: query.isFetching,
|
||||||
isPlaceholderData: query.isPlaceholderData,
|
isPlaceholderData: query.isPlaceholderData,
|
||||||
error: query.error,
|
error: query.error,
|
||||||
|
|||||||
Reference in New Issue
Block a user