Skip to content

Instantly share code, notes, and snippets.

@yingmu52
Created July 20, 2017 04:30
Show Gist options
  • Save yingmu52/5990cf5969e3a8a7f8053f44d0a5eb0f to your computer and use it in GitHub Desktop.
Save yingmu52/5990cf5969e3a8a7f8053f44d0a5eb0f to your computer and use it in GitHub Desktop.
Navigation example
import React from 'react';
import { StyleSheet, Text, View, Image, TextInput, Button } from 'react-native';
import { StackNavigator } from 'react-navigation';
class HomeScreen extends React.Component {
static navigationOptions = {
title: 'HomeScreen',
};
render() {
const { navigate } = this.props.navigation;
return (
<Button title="Go to Jane's profile" onPress={() => navigate('Profile', { name: 'Jane' })}/>
);
}
}
class ProfileScreen extends React.Component {
static navigationOptions = {
title: 'ProfileScreen',
};
render() {
return (
<Text>Fuck you bitches</Text>
);
}
}
export default App = StackNavigator({
Home: { screen: HomeScreen },
Profile: { screen: ProfileScreen },
});
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment