Olá, estou com dificuldade de utilizar o react navigation
segue o codigo :
import React from 'react';
import { StyleSheet, Text, View, TouchableOpacity,} from 'react-native';
import Home from './screens/Home';
import { createStackNavigator } from 'react-navigation';
import Login from './screens/Login';
import Login2 from './screens/Login2';
import Login3 from './screens/Login3';
const RootStack = createStackNavigator({
Home: Home,
Login: Login,
})
export default class App extends React.Component {
render() {
return <RootStack/>
}
}
Agora na Home:
import React from 'react';
import { StyleSheet, Text, View, TouchableOpacity,} from 'react-native';
export default class Home extends React.Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.title}>Hello</Text>
<View style={styles.buttons}>
<TouchableOpacity
style={styles.submit}
onPress={() => this.props.navigation.navigate('Login')}
underlayColor='#fff'>
<Text style={styles.submitText}>Sign in</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.submit}
//onPress={() => this.submitSuggestion(this.props)}
underlayColor='#fff'>
<Text style={styles.submitText}>Log in</Text>
</TouchableOpacity>
</View>
</View>
);
}
}
Quando clico em login, eu tenho o seguinte erro : undefined is not an object (evaluating 'this2.props.navigation.navigate') como posso solucionar isso ?
edit: Quando eu tento chamar uma const e atribuir o valor this.props.navigation para navigate tambem não funciona
obrigado