Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bbb169
Copy link

@bbb169 bbb169 commented Sep 4, 2024

…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
Copy link

CLAassistant commented Sep 4, 2024

CLA assistant check
All committers have signed the CLA.

@crazylxr
Copy link
Collaborator

需要补一下文档和单测哈

@@ -65,16 +79,16 @@ const useInfiniteScroll = <TData extends Data>(
},
);

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

@crazylxr crazylxr Sep 22, 2024

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
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
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