Last active
February 28, 2019 10:02
-
-
Save dwijonarko/d46587c35b0477b88b2e3d1bab86e0ad to your computer and use it in GitHub Desktop.
React 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 HomePage from "./src/HomePage"; | |
import ProfilePage from "./src/ProfilePage"; | |
import {createStackNavigator,createAppContainer} from 'react-navigation' | |
const Navigasi =createStackNavigator( | |
{ | |
Home:HomePage, | |
Profile:ProfilePage | |
} | |
) | |
const AppContainer = createAppContainer(Navigasi) | |
export default class App extends React.Component { | |
render() { | |
return ( | |
<AppContainer /> | |
); | |
} | |
} |
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, { Component } from 'react'; | |
import { View, Text,Button } from 'react-native'; | |
export default class HomePage extends Component { | |
render() { | |
return ( | |
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> | |
<Button | |
title="Go to Profile" | |
onPress={() => { | |
this.props.navigation.navigate('Profile'); | |
}} | |
/> | |
</View> | |
); | |
} | |
} |
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, { Component } from 'react' | |
import { Text, View,Button } from 'react-native' | |
export default class ProfilePage extends Component { | |
render() { | |
return ( | |
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> | |
<Button | |
title="Go to Home" | |
onPress={() => this.props.navigation.navigate('Home')} | |
/> | |
<Button | |
title="Go back" | |
onPress={() => this.props.navigation.goBack()} | |
/> | |
</View> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment