未定义不是对象(评估_this3.props.navigation.navigate)

时间:2018-11-27 14:09:59

标签: javascript reactjs react-native react-navigation

user.js

  <TouchableHighlight onPress={() => 
         this.props.navigation.navigate('SettingsName') } >
     <Text>Name</Text>
   </TouchableHighlight>

App.js

  import React, { Component } from 'react';
  import { Platform, StyleSheet, Text, View, Image } from 'react-native';
  import { createStackNavigator } from 'react-navigation';
  import LoggedOut from './src/screens/LoggedOut';
  import EnterMobile from './src/screens/EnterMobile';
  import EnterOtp from './src/screens/EnterOtp';
  import SplashScreen from './src/screens/SplashScreen';
  import EventsCalendar from './src/screens/EventsCalendar';
  import LocateMe from './src/screens/LocateMe';                    import 
   SettingsName from './src/screens/SettingsName';
  import SettingsProfilePicture from './src/screens/SettingsProfilePicture';
  import SettingsParking from './src/screens/SettingsParking';

 const AppNavigator = createStackNavigator(
  {
   SplashScreen: {
   screen: SplashScreen
  },
 EnterMobile: {
   screen: EnterMobile
 },
 EnterOtp: {
  screen: EnterOtp
 },
  LocateMe: {
   screen: LocateMe
  },
 UserData: {
   screen: UserData
 },
 SettingsLanguage: {
  screen: SettingsLanguage
 },
 SettingsService: {
   screen: SettingsService
 },
 SettingsHoliday: {
   screen: SettingsHoliday
 }
 },
{
 navigationOptions: {
   header: null
 }
});

export default AppNavigator;

导航是在子组件中进行的,是否可能导致不同的行为? 使用stacknavigator,当我单击按钮时,出现以下错误

  

“未定义不是对象(正在评估this3.props.navigation.navigate)”。

0 个答案:

没有答案