-
Notifications
You must be signed in to change notification settings - Fork 0
/
40_react-native_navigation.js
42 lines (31 loc) · 1.02 KB
/
40_react-native_navigation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React,{useEffect,useState} from 'react';
import {Platform,Button, Text,StatusBar, View,ActivityIndicator,StyleSheet,Modal,Pressable } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
const Stack = createNativeStackNavigator();
const App = () => {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Login" component={Login} />
<Stack.Screen name="Home" component={Home} />
</Stack.Navigator>
</NavigationContainer>
);
}
const Home = () => {
return(
<View style={{flex:1,justifyContent:'center',alignItems:'center'}}>
<Text style={{fontSize:20}}>Home</Text>
</View>
)
}
const Login = (props) => {
return (
<View style={{flex:1,justifyContent:'center',alignItems:'center'}}>
<Text style={{fontSize:20}}>Login</Text>
<Button title="Go to home page" onPress={()=>props.navigation.navigate("Home")} />
</View>
)
}
export default App;