@@ -20,13 +20,73 @@ To use this navigator, ensure that you have [`@react-navigation/native` and its
2020npm install @react-navigation/bottom-tabs@next
2121```
2222
23- ## API Definition
23+ ## Usage
2424
25- To use this tab navigator, import it from ` @react-navigation/bottom-tabs ` :
25+ To use this navigator, import it from ` @react-navigation/bottom-tabs ` :
2626
27- <samp id =" tab-based-navigation-minimal " />
27+ <Tabs groupId =" config " queryString =" config " >
28+ <TabItem value =" static " label =" Static " default >
2829
29- ``` js
30+ ``` js name="Bottom Tab Navigator" snack version=7
31+ import * as React from ' react' ;
32+ import { Text , View , Button } from ' react-native' ;
33+ import { createStaticNavigation , useNavigation } from ' @react-navigation/native' ;
34+ // codeblock-focus-start
35+ import { createBottomTabNavigator } from ' @react-navigation/bottom-tabs' ;
36+
37+ // codeblock-focus-end
38+ function HomeScreen () {
39+ const navigation = useNavigation ();
40+
41+ return (
42+ < View style= {{ flex: 1 , alignItems: ' center' , justifyContent: ' center' }}>
43+ < Text > Home Screen< / Text >
44+ < Button
45+ title= " Go to Profile"
46+ onPress= {() => navigation .navigate (' Profile' )}
47+ / >
48+ < / View>
49+ );
50+ }
51+
52+ function ProfileScreen () {
53+ const navigation = useNavigation ();
54+
55+ return (
56+ < View style= {{ flex: 1 , alignItems: ' center' , justifyContent: ' center' }}>
57+ < Text > Profile Screen< / Text >
58+ < Button
59+ title= " Go to Home"
60+ onPress= {() => navigation .navigate (' Home' )}
61+ / >
62+ < / View>
63+ );
64+ }
65+
66+ // codeblock-focus-start
67+ const MyTabs = createBottomTabNavigator ({
68+ screens: {
69+ Home: HomeScreen,
70+ Profile: ProfileScreen,
71+ },
72+ });
73+ // codeblock-focus-end
74+
75+ const Navigation = createStaticNavigation (MyTabs);
76+
77+ export default function App () {
78+ return < Navigation / > ;
79+ }
80+ ```
81+
82+ </TabItem >
83+ <TabItem value =" dynamic " label =" Dynamic " >
84+
85+ ``` js name="Bottom Tab Navigator" snack version=7
86+ import * as React from ' react' ;
87+ import { Text , View , Button } from ' react-native' ;
88+ import { NavigationContainer , useNavigation } from ' @react-navigation/native' ;
89+ // codeblock-focus-start
3090import { createBottomTabNavigator } from ' @react-navigation/bottom-tabs' ;
3191
3292const Tab = createBottomTabNavigator ();
@@ -35,18 +95,60 @@ function MyTabs() {
3595 return (
3696 < Tab .Navigator >
3797 < Tab .Screen name= " Home" component= {HomeScreen} / >
38- < Tab .Screen name= " Settings " component= {SettingsScreen } / >
98+ < Tab .Screen name= " Profile " component= {ProfileScreen } / >
3999 < / Tab .Navigator >
40100 );
41101}
102+ // codeblock-focus-end
103+
104+ function HomeScreen () {
105+ const navigation = useNavigation ();
106+
107+ return (
108+ < View style= {{ flex: 1 , alignItems: ' center' , justifyContent: ' center' }}>
109+ < Text > Home Screen< / Text >
110+ < Button
111+ title= " Go to Profile"
112+ onPress= {() => navigation .navigate (' Profile' )}
113+ / >
114+ < / View>
115+ );
116+ }
117+
118+ function ProfileScreen () {
119+ const navigation = useNavigation ();
120+
121+ return (
122+ < View style= {{ flex: 1 , alignItems: ' center' , justifyContent: ' center' }}>
123+ < Text > Profile Screen< / Text >
124+ < Button
125+ title= " Go to Home"
126+ onPress= {() => navigation .navigate (' Home' )}
127+ / >
128+ < / View>
129+ );
130+ }
131+
132+ export default function App () {
133+ return (
134+ < NavigationContainer>
135+ < MyTabs / >
136+ < / NavigationContainer>
137+ );
138+ }
42139```
43140
141+ </TabItem >
142+ </Tabs >
143+
44144::: note
45145
46- For a complete usage guide please visit [ Tab Navigation] ( tab-based-navigation.md )
146+ For a complete usage guide see [ Tab Navigation] ( tab-based-navigation.md ) .
47147
48148:::
49149
150+ ## API Definition
151+
50152### Props
51153
52154The ` Tab.Navigator ` component accepts following props:
0 commit comments