React native 单击react native中的按钮时导航

React native 单击react native中的按钮时导航,react-native,React Native,我可以在我的项目中成功地实现堆栈和选项卡导航 import React from "react"; import { StackNavigator } from "react-navigation"; import { TabNavFooter } from "./TabNavFooter"; import { SIGNIN_KEY, SIGNUP_KEY } from "../config/routeKeys"; import { SignupScreen, SigninScreen,

我可以在我的项目中成功地实现堆栈和选项卡导航

import React from "react";
import { StackNavigator } from "react-navigation";
import { TabNavFooter } from "./TabNavFooter";
import { SIGNIN_KEY, SIGNUP_KEY } from "../config/routeKeys";
import {
  SignupScreen,
  SigninScreen,
  MainFeedScreen,
  ProfilePageScreen,
  CommentScreen
} from "../screens";

export const Routes = StackNavigator({
  signin: { screen: SigninScreen },
  comments: { screen: CommentScreen },
  mainfeed: { screen: TabNavFooter },
  signup: { screen: SignupScreen },
  profilePage: { screen: ProfilePageScreen }
});
现在我想在单击“注释”按钮时导航。我的路由在router/index.js文件中。当我在另一个组件上时,如何使用它进行导航?我试过了,但没用

export default class Post extends Component {
  constructor(props) {
    super(props);
  }


  commentPressedHandler = () => {
    this.props.navigation('comments');
  };

您应该像这样添加
navigate
this.props.navigation.navigate(“您的屏幕”)

因此,请尝试更改您的代码,如:

commentPressedHandler = () => {
  this.props.navigation.navigate('comments');
};
而不是:

commentPressedHandler = () => {
  this.props.navigation('comments');
};

this.props.navigation.navigate('comments'))