yingmu52
7/20/2017 - 4:30 AM

Navigation example

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',
  },
});