Skip to content

Instantly share code, notes, and snippets.

@GingerBear
Created March 15, 2017 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GingerBear/6aedca970faae3d4cbd662e01b982f85 to your computer and use it in GitHub Desktop.
Save GingerBear/6aedca970faae3d4cbd662e01b982f85 to your computer and use it in GitHub Desktop.
react-navigation push and pop
// "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