【问题标题】:using switch navigator: object (evaluating '_this.props.navigation.navigate') undefined使用开关导航器:对象(评估'_this.props.navigation.navigate')未定义
【发布时间】:2020-09-16 11:58:08
【问题描述】:

我正在使用本机反应,但我不断收到此错误。 undefined 不是对象(评估 '_this.props.navigation.navigate')

当我单击登录页面上的 onPress 按钮时。有人可以帮忙吗?

 <Button
   title="Don't have an account yet? Sign up"
    onPress={() => this.props.navigation.navigate("Signup")}
 />

// 我的登录页面 //

enter image description here

// 我的导航页面 //

enter image description here

【问题讨论】:

  • 截图中的代码看起来不错。我在世博会尝试了相同的代码。有用。这是它的链接snack.expo.io/dkJozSSr8。检查您是否缺少任何东西。
  • 可能是您的 Signup.js 页面存在问题。
  • 感谢@Sriram,我错过了导入,感谢您的帮助

标签: javascript react-native react-props navigator onpress


【解决方案1】:

尝试在你的渲染函数中添加这个。然后调用 navigate("Signup")

render() {
    const { navigate } = this.props.navigation; // add this
    return (

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-24
    • 1970-01-01
    • 1970-01-01
    • 2021-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多