-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support userInfiniteScroll use forcedLoadMore to keep requestin… #2640
base: master
Are you sure you want to change the base?
Conversation
…g when data is no more
需要补一下文档和单测哈 |
@@ -65,16 +79,16 @@ const useInfiniteScroll = <TData extends Data>( | |||
}, | |||
); | |||
|
|||
const loadMore = useMemoizedFn(() => { | |||
const loadMore = useMemoizedFn((isNeedForcedLoadMore = false) => { | |||
if (noMore) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我理解这个好像没那么复杂,不需要写很多复杂的逻辑,其他的逻辑都删掉,直接:
if(!isNeedForcedLoadMore && noMore) {
return;
}
是不是就好了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我理解这个好像没那么复杂,不需要写很多复杂的逻辑,其他的逻辑都删掉,直接:
if(!isNeedForcedLoadMore && noMore) { return; }
是不是就好了
会有问题的,当滚动到下方时,如果不判断
else if (scrollHeight - scrollTop <= clientHeight) { loadMore(true); }
会导致它一直触发loadMore,需要加一层判断来确认是用户主动向下滚动,而不是考虑threshold的距离
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你又改 api 了呀,如果实现 forceLoadMore,从 api 的设计上 我认为在loadMore 的时候增加一个参数,是否忽略 noMore,比增加一个配置更好,逻辑处理也比较简单
function loadMore(ignoreNoMore: bolean) {
}
你看看呢
…g when data is no more
[中文版模板 / Chinese template]
🤔 This is a ...
🔗 Related issue link
#2180
💡 Background and solution
forcedLoadMore
, when this value is set true, user scroll list to bottom will cause request again📝 Changelog
forcedLoadMore
and new returned resulttrulyNoMore
forcedLoadMore
和返回结果增加参数trulyNoMore
☑️ Self Check before Merge