导航器在React Native App中不起作用(参数0(NSNumber))

use*_*337 9 react-native

我试图在视图之间导航以在React Native中工作,如下所示:

newUserFlow() {
    this.props.navigator.push({
      title: "Create Account",
      component: F8InfoView,
    });
  }

<TopFiveButton
            style={styles.button}
            onPress={this.newUserFlow.bind(this)}
            caption="Create Account"
/>
Run Code Online (Sandbox Code Playgroud)

但是,我在点击时遇到此错误:

ExceptionsManager.js:75 Argument 0 (NSNumber) of RCTNavigatorManager.requestSchedulingJavaScriptNavigation must not be null
Run Code Online (Sandbox Code Playgroud)

这在以前工作,但似乎有些变化.可能是什么问题?谢谢.

调试器在例外manageR中引用它:

  // Flow doesn't like it when you set arbitrary values on a global object
  (console: any)._errorOriginal = console.error.bind(console);
Run Code Online (Sandbox Code Playgroud)

我在打破流量吗?谢谢.

编辑:

index.ios.js看起来像这样:

class nomad extends Component {
  render() {
    return (
      <NavigatorIOS
        style={styles.container}
        initialRoute={{
          title: 'Nomad',
          component: LoginScreen
        }} />
    );
  }
};
Run Code Online (Sandbox Code Playgroud)

然后在LoginScreen中:

class LoginScreen extends React.Component {
  newUserFlow() {
    this.props.navigator.push({
      title: "Create Account",
      component: F8InfoView,
//      passProps: {userInfo: this.props.userInfo}
    })
  }
render() {
    return (
          <F8Button
            style={styles.button}
            onPress={this.newUserFlow.bind(this)}
            caption="Create Account"
          />
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

单击该按钮会给我错误.

A S*_*ANI 0

您使用哪个版本进行反应?您确定使用的是最后一个稳定版本吗?我问你这个是因为在ExceptionsManager.js中,我在第 75 行看不到“NSNumber”...

让我强调一下,这个问题非常相似......所以你有没有尝试过

navigator.push(routes[1]);
Run Code Online (Sandbox Code Playgroud)

在 onPress 属性内。?

就像是:

<F8Button onPress={
    () => { if (route.index === 0){ 
                    navigator.push(routes[1]); 
                } else {
                    navigator.pop(); 
                } 
          }
...
...
Run Code Online (Sandbox Code Playgroud)

最后,您还可以仔细查看https://facebook.github.io/react-native/docs/navigator.html

问候