Created
March 22, 2019 19:43
-
-
Save littleV/b203608e10f4596ef4b2e4cc6cf9b4cc to your computer and use it in GitHub Desktop.
A React Native tab based app example
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 { Button, View, Text } from "react-native"; | |
import { createStackNavigator, createAppContainer } from "react-navigation"; | |
class HomeScreen extends React.Component { | |
render() { | |
return ( | |
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> | |
<Text>Home Screen</Text> | |
<Button | |
title="Go to Details" | |
onPress={() => this.props.navigation.navigate('Details')} | |
/> | |
</View> | |
); | |
} | |
} | |
class DetailsScreen extends React.Component { | |
render() { | |
return ( | |
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}> | |
<Text>Details Screen</Text> | |
</View> | |
); | |
} | |
} | |
const AppNavigator = createStackNavigator( | |
{ | |
Home: HomeScreen, | |
Details: DetailsScreen | |
}, | |
{ | |
initialRouteName: "Home" | |
} | |
); | |
export default createAppContainer(AppNavigator); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment