How to make navigation between two screens in react native?

When compiling this code, I get the error: can't find variable ProfileScreen.

 import { StackNavigator, } from 'react-navigation'; const App = StackNavigator({ Main: {screen: MainScreen}, Profile: {screen: ProfileScreen}, }); class MainScreen extends React.Component { static navigationOptions = { title: 'Welcome', }; render() { const { navigate } = this.props.navigation; return ( <Button title="Go to Jane's profile" onPress={() => navigate('Profile', { name: 'Jane' }) } /> ); } } 

1 answer 1

If this is all code, then you haven’t described ProfileScreen, you can do it like this:

 class ProfileScreen extends React.Component { static navigationOptions = { title: 'Profile', }; render() { return ( <View> <Text>Jane's profile</Text> </View> ); } }