-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathtab-actions.js
executable file
·42 lines (37 loc) · 1.15 KB
/
tab-actions.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 * as React from 'react';
import { View, Button, Text } from 'react-native';
import { NavigationContainer, TabActions } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
function HomeScreen({ navigation }) {
const jumpToAction = TabActions.jumpTo('Profile', { user: 'Satya' });
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Home!</Text>
<Button
title="Jump to Profile"
onPress={() => navigation.dispatch(jumpToAction)}
/>
</View>
);
}
function ProfileScreen({ route }) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Profile!</Text>
<Text>
{route?.params?.user ? route.params.user : 'No one'}'s profile
</Text>
</View>
);
}
const Tab = createBottomTabNavigator();
export default function App() {
return (
<NavigationContainer>
<Tab.Navigator>
<Tab.Screen name="Home" component={HomeScreen} />
<Tab.Screen name="Profile" component={ProfileScreen} />
</Tab.Navigator>
</NavigationContainer>
);
}