getDerivedStateFromProps何时清除数据?

问题描述 投票:0回答:1

getDerivedStateFromProps对于组件是静态的。但是今天我调试了该应用程序,当我们定义相同的内容时,我在getDerivedStateFromProps方法中找到了其他组件数据nextProp.x。

另一种情况是当重新创建组件时,nextProp.x仍保留前数据。

所以当react-native会删除getDerivedStateFromProps数据时,为什么要混合这些数据?

react-native getderivedstatefromprops
1个回答
0
投票

道具是从父母那里得到的,如果它能保留旧数据的话。这可能是由父母造成的。如果使用redux,可能是由它引起的。还原状态不清楚。

© www.soinside.com 2019 - 2024. All rights reserved.