未定义不是评估_this.props.navigation的对象

时间:2019-09-23 10:24:54

标签: react-native

class Login extends Component {
render() {
    const {navigate} = this.props.navigation;
    return (
      <Card>
        <CardSection>
          <Button onPress={() => navigate('SignUp')}>
             ForgotPass?
         </Button>

        </CardSection>
      </Card>
    );
  }
}

这是我的代码,我尝试转到“ SignUp”页面,但未成功。有人吗 为什么它不起作用? 我知道这是一个简单的问题,但是我尝试了很多次却没有成功

import {createStackNavigator} from 'react-navigation-stack';
import { createAppContainer } from 'react-navigation';
import FirstScreen from './src/HomePage/FirstScreen';
import Login from './src/Login/Login';
import LogOut from './src/LogOut/LogOut';
import SignUp from './src/SignUp/SignUp';
import HomeScreen from './src/HomeScreen';
import ProfileScreen from './src/ProfileScreen';


const MainNavigator = createStackNavigator(
  {

  First: FirstScreen,
  LogOut : LogOut,
  Login: Login,
  SignUp: SignUp,
  Home: HomeScreen,
  Profile: ProfileScreen,
  },
  {
  initialRouteName : 'First',
  defaultNavigationOptions: {
    title: "FrienDog"
  }
}
);

const App = createAppContainer(MainNavigator);


export default App;

这是我的app.js文件,我无法移至注册页面。 请帮我。 谢谢。

1 个答案:

答案 0 :(得分:0)

class Login extends Component {
render() {
    return (
     <Container>
       <Card>
         <CardSection>
           <Button onPress={()=>this.props.navigation.navigate('SignUp')}
             title='ForgotPass?'>
         </Button>
        </CardSection>
      </Card>
    </Container>
    );
  }
}