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

getScrollContainer不稳定(涉及ref),导致children创建多次的问题 #171

Open
lizongze opened this issue Sep 29, 2020 · 0 comments

Comments

@lizongze
Copy link

lizongze commented Sep 29, 2020

getScrollContainer不应该有默认函数,只要定义了该函数,就不需要额外渲染一个ScrollContainer了

如果用户返回一个ref,这个ref只会在ComponentDidMount时才不为undefined,导致进入了需要渲染ScrollContainer的分支,ref取到后,又进入了不需要渲染ScrollContainer的分支,这时children就被多创建了一次。

情景:

  • 引发了我这边一个数据问题,数据不对了;

  • 我这边的一些操作可能在children第一次被创建时就走过了,然后走了些异步逻辑,回来发现相关引用都变成新的了,由于二次创建又走了相关的周期覆盖了最开始的引用。这时多个异步流程链里,前面的拿的是第一次的引用,后面的拿的是第二次的引用,从而引发了一些潜在的bug

临时解法:

          getScrollContainer={() => this.scrollViewRef || {}}
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

No branches or pull requests

1 participant