fix: keep pagination lock effect-local

This commit is contained in:
2026-07-13 21:54:02 +09:00
parent aac376a571
commit ed0448e3de
+3 -4
View File
@@ -6,9 +6,7 @@ import { PostCard } from './post-card'
export function PostFeed({ request }: { request: FeedRequest | undefined }) {
const query = usePostFeed(request)
const sentinel = useRef<HTMLDivElement>(null)
const fetchingNextPage = useRef(query.isFetchingNextPage)
const posts = query.data ? flattenPostPages(query.data.pages) : []
fetchingNextPage.current = query.isFetchingNextPage
useEffect(() => {
if (
@@ -20,10 +18,11 @@ export function PostFeed({ request }: { request: FeedRequest | undefined }) {
return
}
let requested = false
const observer = new IntersectionObserver(
([entry]) => {
if (entry?.isIntersecting && !fetchingNextPage.current) {
fetchingNextPage.current = true
if (entry?.isIntersecting && !requested) {
requested = true
void query.fetchNextPage()
}
},