Skip to content

feat: support userInfiniteScroll use forcedLoadMore to keep requestin… - #2640

Open
bbb169 wants to merge 2 commits into
alibaba:masterfrom
bbb169:feature/force-load-more
Open

feat: support userInfiniteScroll use forcedLoadMore to keep requestin…#2640
bbb169 wants to merge 2 commits into
alibaba:masterfrom
bbb169:feature/force-load-more

Conversation

@bbb169

@bbb169 bbb169 commented Sep 4, 2024

Copy link
Copy Markdown

…g when data is no more

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

#2180

💡 Background and solution

  1. user need ability to keep requesting when scroll list's data is no more
  2. add an new props named forcedLoadMore, when this value is set true, user scroll list to bottom will cause request again

📝 Changelog

Language Changelog
🇺🇸 English add new props forcedLoadMore and new returned result trulyNoMore
🇨🇳 Chinese 添加新参数 forcedLoadMore和返回结果增加参数 trulyNoMore

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@CLAassistant

CLAassistant commented Sep 4, 2024

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@crazylxr

Copy link
Copy Markdown
Collaborator

需要补一下文档和单测哈


const loadMore = useMemoizedFn(() => {
const loadMore = useMemoizedFn((isNeedForcedLoadMore = false) => {
if (noMore) return;

@crazylxr crazylxr Sep 22, 2024

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我理解这个好像没那么复杂,不需要写很多复杂的逻辑,其他的逻辑都删掉,直接:

if(!isNeedForcedLoadMore && noMore) {
 return;
}

是不是就好了

Copy link
Copy Markdown
Author

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的距离

Copy link
Copy Markdown
Collaborator

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) {
}

你看看呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants