How to pass navigator reference to React Native ?

前端 未结 3 1792
时光说笑
时光说笑 2021-01-28 07:38

Using react-native-drawer ( https://github.com/root-two/react-native-drawer ) in my index.ios.js, I have the following set up and trying to pass \'navigator\' reference into con

3条回答
  •  长发绾君心
    2021-01-28 08:27

    This is how it should be done. You save the navigator reference form renderScene method define a getter method, pass the method to the component you want.

    class practice extends Component {
        ...
        renderScene(route, navigator){
            this._navigator = navigator
        }
    
        configureScene(route, routeStack){
            ...
        }
         
        getNav = () => {
          return this._navigator
        }
    
        render() {
            return (
              }
                ...
              >
                 this.renderScene(route, navigator)}
                  style={styles.container}
                  navigationBar={
                    
                  }
                />
             
        );
      }
    }

提交回复
热议问题