ios - 通过 NavigatorIOS 传递 Redux 状态

标签 ios navigation react-native redux

我正在将 Redux 集成到 React Native 应用程序中。我无法弄清楚如何通过 NavigatorIOS 组件传递 Redux 状态。

当执行进入下图组件时,调试器显示

Prop = 对象 {状态:未定义, Action :对象} 随着 Action 对象中的预期 Action ,状态尚未定义,因为它尚未初始化(我假设)。

但是当执行进入 ItemIndex 组件时,调试器显示 props = Object {导航器:对象,路线:对象}

我当前的实现试图显式地传递状态和操作,但它们没有通过:调试器现在显示 props = Object {navigator: Object, route: Object, state: null, actions: undefined}

class MainComponent extends Component {
  constructor(props) {
    super(props) 
    const { actions, state } = props
  }

  render() {
    return (
      <NavigatorIOS
        ref = "nav"
        style = {styles.navigator}
        initialRoute = {{
          // Pass redux state into component
          passProps: { state: this.state, actions: this.actions },  
          // currently becomes { state: null, actions: undefined }
          title: 'Items',
          component: ItemIndex
        }}/> 
    )
  }
}

module.exports = MainComponent

有没有一种方法可以让我继续通过 NavigatorIOS 向下传递 Redux 状态?

最佳答案

react-native-navigation支持 Redux,使用原生 iOS View Controller (通过 react-native-controllers 而不是 navigatorIOS)并且很快将支持 Android。到目前为止,这是满足我需求的最佳导航解决方案。

关于ios - 通过 NavigatorIOS 传递 Redux 状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35366436/

相关文章:

html - 水平导航栏在 IE 和 Firefox 中不起作用

html - 下拉菜单悬停效果的困难

android - ViewPagerAndroid 不使用 React-Native 在 ScrollView 下渲染

ios - 此错误是什么意思?

ios - 无法弄清楚为什么过早释放对象

ios - iOS模拟器中的文件排列

iphone - 在 objective-c 中保留按值传递的变量是否可以?

css - 如何使子菜单具有与菜单 CSS/HTML5 相同的宽度

react-native - Ionic 2 webview 或 native

javascript - 发送前检查axios请求url