Search code examples
react-nativereact-navigationreact-navigation-stack

switch navigator throws an error "undefined is not an object ( 'this.props')"


I dont know what to do here i've tried stack navigator also same issue with props ;/

Enter Screen

...
export default function App(props) {
    return (     
       <View style={{flex:1 , justifyContent:'center', alignItems:'center'}}> 
       <TouchableOpacity onPress={()=>{ 
         console.log(props)
       this.props.navigation.navigate('Home')
         //this.props.navigation.dispatch(SwitchActions.jumpTo('Home'))
         } } >
         <Text>switch test</Text>
       </TouchableOpacity>
       </View>   
    );
}...

Navigation

...
const SwitchNavigation = createStackNavigator({
 Enter:{screen : EnterScreen},
 Home:{ screen :HomeScreen}
})...
export default createAppContainer(SwitchNavigation);

APP

...
export default function App(props) {
  return (
       <NavigaitonScreens />
  );
}...

Solution

  • It has nothing to do with navigation.

    There is No this in functional-component ...

    access props directly like props.navigation.navigate('Home')