Created
March 15, 2017 22:39
-
-
Save GingerBear/6aedca970faae3d4cbd662e01b982f85 to your computer and use it in GitHub Desktop.
react-navigation push and pop
This file contains hidden or 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
// "react-native": "0.42.0", | |
// "react-navigation": "^1.0.0-beta.7" | |
/** | |
* Sample React Native App | |
* https://github.com/facebook/react-native | |
* @flow | |
*/ | |
import React, { Component } from 'react'; | |
import { | |
AppRegistry, | |
StyleSheet, | |
Text, | |
View, | |
Button | |
} from 'react-native'; | |
import { StackNavigator, TabNavigator } from 'react-navigation'; | |
class ChatScreen extends React.Component { | |
static navigationOptions = { | |
title: 'Chat with Lucy', | |
}; | |
render() { | |
const { navigate } = this.props.navigation; | |
return ( | |
<View> | |
<Text>Chat with Lucy</Text> | |
<Button | |
onPress={() => navigate('Chat')} | |
title="Chat with Lucy" | |
/> | |
</View> | |
); | |
} | |
} | |
class HomeScreen extends React.Component { | |
static navigationOptions = { | |
title: 'Welcome', | |
}; | |
render() { | |
const { navigate } = this.props.navigation; | |
return ( | |
<View> | |
<Text>Hello, Chat App!</Text> | |
<Button | |
onPress={() => navigate('Chat')} | |
title="Chat with Lucy" | |
/> | |
</View> | |
); | |
} | |
} | |
const SimpleApp = StackNavigator({ | |
Home: { screen: HomeScreen }, | |
Chat: { screen: ChatScreen }, | |
}); | |
AppRegistry.registerComponent('TestReactNavigation', () => SimpleApp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment