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

fix(taro-weapp): 在 diffObjToPath 时,如果目标数组为空,强制进行一次 setData 将其清空 #2453

Closed
wants to merge 1 commit into from

Conversation

Leechael
Copy link
Contributor

非 Page 类型组件 C,父级组件 P 通过 Props 传递 Array 类型的参数。在一些复杂状态的情况下,会出现赋值时,组件 C 记住了上一次 Array 的数组内容,而传递一个空 Array 进去时没有正确更新进去。此时因为信息不同步,diffObjToPathtoItemfromItem 一致,但实际渲染这个 Array 时,是存在数据的。

针对这个情况,这一补丁针对 toItem 是 Array 并且是 length 为 0 的情况下,强制通知 setData 进行一次更新这个 Array 类型的数据(强制进行清空)。

@Chen-jj
Copy link
Contributor

Chen-jj commented Apr 1, 2019

@Leechael 提供一下问题代码或测试用例吧。

新数组为 [] 时,长度肯定小于等于旧数组。小于时,当前逻辑已经是会更新了,等于时不需要更新也是正确的。所以不太明白你遇到什么问题。

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.

None yet

3 participants