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

InfiniteScroll 组件懒加载时会无限调用loadMore #5912

Closed
puchenhui opened this issue Jan 4, 2023 · 2 comments
Closed

InfiniteScroll 组件懒加载时会无限调用loadMore #5912

puchenhui opened this issue Jan 4, 2023 · 2 comments
Labels

Comments

@puchenhui
Copy link

Version of antd-mobile

5.18.0

Operating system and its version

iOS, Android

Browser and its version

所有

Sandbox to reproduce

No response

What happened?

出现的问题:在懒加载时会无限重复请求
期望:只加载一次

Relevant log output

// 无限加载方法
const loadMoreData = () => {
        return getPointPage(inputShowValue, filterPage + 1)
    };

    // 获取接口
    const getPointPage = (value: string, page?: number = 1) => {
        const params = {
            keywords: value,
            current: page,
            size: 20
        }
        return getPointListPage(params).then((res: any) => {
            setFilterPage(page)
            if (filterPage === 1) {
                setPointPage(res.records)
            } else {
                setPointPage(pointPage.concat(res.records));
            }

            setTotal(res.total)
        })
    }

// 组件
<InfiniteScroll
                  loadMore={loadMoreData}
                  hasMore={pointPage.length < total}
                  threshold={250}
                >
                    // 这个loading
                    <InfiniteScrollContent 
                      hasMore={pointPage.length < total} 
                      page={pointPage.length > 10 ? 
                    pointPage.length / 10 : 1}
                    />
                </InfiniteScroll>
@puchenhui puchenhui added the bug label Jan 4, 2023
@puchenhui
Copy link
Author

我是在taro框架里用的InfiniteScroll这个组件

@ycshill
Copy link

ycshill commented Aug 7, 2024

我是在taro框架里用的InfiniteScroll这个组件

怎么解决的呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants