Skip to content

Instantly share code, notes, and snippets.

@AllanGraves
Last active January 5, 2021 19:24
Show Gist options
  • Save AllanGraves/a2a8a01b69ff8967834067b3579b941e to your computer and use it in GitHub Desktop.
Save AllanGraves/a2a8a01b69ff8967834067b3579b941e to your computer and use it in GitHub Desktop.
Setting up a basic Stack Navigator
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