Last active
January 5, 2021 19:24
-
-
Save AllanGraves/a2a8a01b69ff8967834067b3579b941e to your computer and use it in GitHub Desktop.
Setting up a basic Stack Navigator
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-native-gesture-handler'; | |
import React from 'react'; | |
import {NavigationContainer} from '@react-navigation/native'; | |
import {SafeAreaView, ScrollView, View, Text, StatusBar} from 'react-native'; | |
const ScreenOne = () => { | |
return ( | |
<View> | |
<Text> Screen One </Text> | |
</View> | |
); | |
}; | |
const ScreenTwo = () => { | |
return ( | |
<View> | |
<Text> Screen Two </Text> | |
</View> | |
); | |
}; | |
const ScreenThree = () => { | |
return ( | |
<View> | |
<Text> Screen Three </Text> | |
</View> | |
); | |
}; | |
import {createStackNavigator} from '@react-navigation/stack'; | |
const Stack = createStackNavigator(); | |
const StackScreens = () => { | |
return ( | |
<Stack.Navigator> | |
<Stack.Screen name="One" component={ScreenOne} /> | |
<Stack.Screen name="Two" component={ScreenTwo} /> | |
<Stack.Screen name="Three" component={ScreenThree} /> | |
</Stack.Navigator> | |
); | |
}; | |
const App: () => React$Node = () => { | |
return ( | |
<> | |
<NavigationContainer> | |
<StatusBar barStyle="dark-content" /> | |
<StackScreens /> | |
</NavigationContainer> | |
</> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment