【问题标题】:getDerivedStateFromProps when to clear data?getDerivedStateFromProps 何时清除数据?
【发布时间】:2019-11-29 07:36:30
【问题描述】:

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

另一种情况是当一个组件被重新创建时,nextProp.x 仍然是 pre-data。

那么当 react-native 会移除 getDerivedStateFromProps 数据时,为什么数据是混合的呢?

【问题讨论】:

    标签: react-native getderivedstatefromprops


    【解决方案1】:

    props 是从 parent 获取的,如果它 remians 旧数据。它可能由父母引起。如果你使用redux,可能是它造成的。归约状态不明确。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-09
      • 1970-01-01
      • 1970-01-01
      • 2015-09-08
      相关资源
      最近更新 更多