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

useInfiniteScroll在切换tab场景下执行两次的问题 #1652

Open
taoliujun opened this issue Jun 5, 2022 · 6 comments
Open

useInfiniteScroll在切换tab场景下执行两次的问题 #1652

taoliujun opened this issue Jun 5, 2022 · 6 comments
Labels

Comments

@taoliujun
Copy link

taoliujun commented Jun 5, 2022

有一个业务场景是tab切换后请求接口,所以在useInfiniteScroll中设置了reloadDeps。造成一个问题如下:

  1. 切换第一个tab,返回了一些数据,且nextId: 12
  2. 切换第二个tab,返回了一些数据,且nextId: null
  3. 紧接着,又自动请求了接口,并且请求参数为 nextId: 12

打断点发现,是scroll监听事件执行的时候,finalData和noMore仍然是上一个声明周期中的值。这有极大几率发生,取决于setFinalData的执行效率如何。

@crazylxr
Copy link
Collaborator

crazylxr commented Jun 6, 2022

麻烦放一个 demo 呢

@miracles1919 miracles1919 added the 🤔 Need Reproduce We cannot reproduce your problem label Jul 20, 2022
@github-actions
Copy link

Hello @taoliujun. Please provide a online reproduction by forking this link https://codesandbox.io/s/ok2fe or a minimal GitHub repository. Issues labeled by Need Reproduce will be closed if no activities in 3 days.

你好 @taoliujun, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击 此处 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。3 天内未跟进此 issue 将会被自动关闭。

@soulcm
Copy link

soulcm commented Feb 27, 2023

+1 遇到了,就没人管么,类似问题的pr都被close了

@crazylxr
Copy link
Collaborator

+1 遇到了,就没人管么,类似问题的pr都被close了

麻烦放一个在线 能复现的 demo。

@crazylxr crazylxr reopened this Feb 27, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 3, 2023
@liuyib liuyib reopened this Mar 3, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 7, 2023
@crazylxr crazylxr reopened this Mar 7, 2023
@liuyib
Copy link
Collaborator

liuyib commented Mar 9, 2023

复现了一个类似的:https://codesandbox.io/s/ahooks-1652-issue-useinfinitescrollzai-qie-huan-tabchang-jing-xia-zhi-xing-liang-ci-de-wen-ti-ejpv7z?file=/App.tsx:1060-1064

但我这是为了复现而故意为之的:

image

不知道真实用户会不会这样用,按理来说应该直接用 useInfiniteScroll 返回的 data 数据渲染 UI 的。
@crazylxr

@liuyib
Copy link
Collaborator

liuyib commented Mar 9, 2023

@taoliujun @soulcm 可以给个你们的在线 demo 吗?

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 13, 2023
@liuyib liuyib added question and removed 🤔 Need Reproduce We cannot reproduce your problem labels Mar 13, 2023
@liuyib liuyib reopened this Mar 13, 2023
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

5 participants