Pass Redux State through NavigatorIOS

I'm in the process of integrating Redux into a React Native app. I'm having problems with how to pass Redux state through the NavigatorIOS component.

When execution enters the component shown below, the debugger shows

props = Object {state: undefined, actions: Object} With the expected actions in the action object and still undefined, since it has not yet been initialized (suppose).

However, when execution enters the ItemIndex component, the debugger shows props = Object {navigator: Object, route: Object}

My current implementation is trying to explicitly convey state and actions, but they cannot be pulled out: now the debugger shows 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

Is there a way to continue passing Redux state with NavigatorIOS?

+4
source share
2

react-native-navigation Redux, iOS ( react-native-controllers navigatorIOS) Android. .

+2

, props :

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

- , , , initialRoute .

0

Source: https://habr.com/ru/post/1628533/


All Articles