Skip to content

Commit

Permalink
fix: infinitescroll组件loadMore执行时机修复
Browse files Browse the repository at this point in the history
  • Loading branch information
kongjing committed Aug 31, 2023
1 parent 5048fee commit 496f527
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/vantui/src/infinite-scroll/infinite-scroll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function InfiniteScroll_(
const reset = useCallback((needLoad?: boolean): Promise<null> => {
return new Promise((resolve) => {
nextTick(() => {
if( needLoad ) setForceKey(Date.now())
if (needLoad) setForceKey(Date.now())
else setForceKey(0)
setStatus('loading')
setOnRequest(false)
Expand All @@ -59,10 +59,13 @@ function InfiniteScroll_(
if ((!onRequest && status === 'loading') || immediately) {
setOnRequest(true)
const status = await loadMore()
// 确保等待渲染任务执行完成
setTimeout(() => {
setStatus(status)
setOnRequest(false)
})
nextTick(() => {
setStatus(status)
setOnRequest(false)
})
}, 60)
}
},
[loadMore, onRequest, status],
Expand Down

0 comments on commit 496f527

Please sign in to comment.