hooks
hooks copied to clipboard
fix(useInfiniteScroll): fix duplicate trigger requests
🤔 This is a ...
- [ ] New feature
- [x] 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
#2878
💡 Background and solution
Background:
- LoadMore was triggered before the initial request ended.
Solution:
- Add status checks before calling loadMore.
📝 Changelog
const loadMore = useMemoizedFn(() => {
// If loading is true do nothing
if (noMore || loading) {
return;
}
setLoadingMore(true);
run(finalData);
});
const loadMoreAsync = useMemoizedFn(() => {
if (noMore || loading) {
return Promise.reject();
}
setLoadingMore(true);
return runAsyncForCurrent(finalData);
});
| Language | Changelog |
|---|---|
| 🇺🇸 English | fix(useInfiniteScroll): fix duplicate trigger requests |
| 🇨🇳 Chinese | fix(useInfiniteScroll): 修复重复的触发请求 |
☑️ 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
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.