Created
July 13, 2017 12:45
-
-
Save jaromirnyklicek/a311abdf58688aaf2a8d887a059798e8 to your computer and use it in GitHub Desktop.
React native app with navigation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {StackNavigator} from "react-navigation"; | |
import {AppRegistry, Button} from "react-native"; | |
class MainScreen extends React.Component { | |
static navigationOptions = { | |
title: 'Main' | |
}; | |
render() { | |
const {navigate} = this.props.navigation; | |
console.log(this.props); | |
return ( | |
<Button | |
title="Profil" | |
onPress={() => navigate('Profile')} | |
/> | |
); | |
} | |
} | |
class ProfileScreen extends React.Component { | |
static navigationOptions = { | |
title: 'Profil' | |
}; | |
render() { | |
const {goBack} = this.props.navigation; | |
return ( | |
<Button | |
title="Go back" | |
onPress={() => goBack()} | |
/> | |
); | |
} | |
} | |
export default StackNavigator({ | |
Main: {screen: MainScreen}, | |
Profile: {screen: ProfileScreen}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment