React native 响应本机导航更新数据

React native 响应本机导航更新数据,react-native,redux,react-navigation,react-native-flatlist,React Native,Redux,React Navigation,React Native Flatlist,我正在构建一个应用程序,使用Redux和React导航库。我有一个简单列表中的训练列表: <FlatList style={{ backgroundColor: colors.background }} data={this.props.workoutsList} renderItem={({ item }) => <ListItem workout={item} onPress={() => this.props.navigation

我正在构建一个应用程序,使用ReduxReact导航库。我有一个简单列表中的训练列表:

<FlatList
    style={{ backgroundColor: colors.background }}
    data={this.props.workoutsList}
    renderItem={({ item }) =>
      <ListItem workout={item} onPress={() => this.props.navigation.navigate('Workout', item)} />
    }
    keyExtractor={(item) => item.id}
  />
我看到了控制台,我的FlatList页面被正确刷新(它没有将我带回正确的滚动位置,因为它刚刚刷新了主列表)……但我总是从React Native收到警告,说:

无法在现有状态转换期间更新(例如在
渲染
或其他组件的构造函数)。渲染方法应该是 道具和状态的纯粹功能;构造函数的副作用是 反模式,但可以移动到
组件willmount


当我将其移动到componentWillMount时,不会调用正确的刷新更改,甚至连console.log-in-componentWillMount都不会显示。

您尝试过scrollToIndex(params:object)
方法吗

此外,如果您想更新flatList中的数据,您应该在Props中添加额外数据


如果您对屏幕使用react navigation goBack(),该屏幕将永远不会触发componentWillMount,因为该屏幕永远不会卸载,因此请改用redux。

您尝试过scrollToIndex(参数:object)
方法吗

此外,如果您想更新flatList中的数据,您应该在Props中添加额外数据


如果对屏幕使用react navigation goBack(),该屏幕将永远不会触发componentWillMount,因为该屏幕永远不会卸载,因此请改用redux。

您进行了哪些调试?更新redux存储时是否调用了
render
?请提供您的操作代码/reducerHi@sooper…谢谢您的关注。我已经用更多的信息更新了我的问题!你做了什么调试?更新redux存储时是否调用了
render
?请提供您的操作代码/reducerHi@sooper…谢谢您的关注。我已经用更多的信息更新了我的问题!
if (this.props.needsRefreshing) {
  console.log('Needs Refreshing');
  this.props.getWorkouts();
}