{"id":957,"date":"2024-09-05T10:13:15","date_gmt":"2024-09-05T10:13:15","guid":{"rendered":"https:\/\/www.freelifemakers.org\/wordpress\/?p=957"},"modified":"2024-09-09T07:55:52","modified_gmt":"2024-09-09T07:55:52","slug":"reactnative-using-tab-navigator","status":"publish","type":"post","link":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/2024\/09\/05\/reactnative-using-tab-navigator\/","title":{"rendered":"[ReactNative]Tab Navigator\uc0ac\uc6a9\ud558\uae30 \/ Using Tab Navigator"},"content":{"rendered":"\n<p>-\ud0ed \ub124\ube44\uac8c\uc774\ud130\ub97c \uc0ac\uc6a9\ud558\ub294 \ubc29\ubc95\uc5d0 \ub300\ud55c \uc124\uba85\uc785\ub2c8\ub2e4.<br>Here&#8217;s an explanation of how to use the tab navigator.<\/p>\n\n\n\n<p>-\ud0ed \ub124\ube44\uac8c\uc774\ud130\ub294 \uc571\uc5d0\uc11c \uc0ac\uc6a9\uac00\ub2a5\ud55c \uba54\ub274\uc758 \ud55c \uc885\ub958 \uc785\ub2c8\ub2e4.<br>Tab navigator is a type of menu available in apps.<\/p>\n\n\n\n<p>-\ud0ed \ub124\ube44\uac8c\uc774\ud130\ub294 \uc571\uc758 \ud558\ub2e8\uc5d0 \ud0ed\uc744 \ud560\ub54c \ud654\uba74 \uc804\ud658\uc744 \ud560 \uc218 \uc788\ub3c4\ub85d \ub3c4\uc640\uc90d\ub2c8\ub2e4.<br>The tab navigator helps you switch screens when you tap at the bottom of the app.<\/p>\n\n\n\n<p>-\ud0ed \ub124\ube44\uac8c\uc774\ud130\uc758 \ubaa8\uc591\uc740 \uc544\ub798 \uc774\ubbf8\uc9c0\uc640 \uac19\uc2b5\ub2c8\ub2e4.<br>The tab navigator will look like the image below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"372\" height=\"442\" src=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/tabNavigator.png\" alt=\"\" class=\"wp-image-958\" srcset=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/tabNavigator.png 372w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/tabNavigator-252x300.png 252w\" sizes=\"auto, (max-width: 372px) 100vw, 372px\" \/><\/figure>\n\n\n\n<p>-\uc544\ub798\ub294 \uc571\uc758 \uc2e4\ud589 \ud654\uba74\uc785\ub2c8\ub2e4.<br>Below is the app launch screen.<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"461\" height=\"1024\" data-id=\"959\" src=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/screen1-461x1024.jpg\" alt=\"\" class=\"wp-image-959\" srcset=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/screen1-461x1024.jpg 461w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/screen1-135x300.jpg 135w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/screen1-768x1707.jpg 768w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/screen1-691x1536.jpg 691w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/screen1-922x2048.jpg 922w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/screen1.jpg 1080w\" sizes=\"auto, (max-width: 461px) 100vw, 461px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"461\" height=\"1024\" data-id=\"960\" src=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/screen2-461x1024.jpg\" alt=\"\" class=\"wp-image-960\" srcset=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/screen2-461x1024.jpg 461w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/screen2-135x300.jpg 135w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/screen2-768x1707.jpg 768w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/screen2-691x1536.jpg 691w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/screen2-922x2048.jpg 922w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/screen2.jpg 1080w\" sizes=\"auto, (max-width: 461px) 100vw, 461px\" \/><\/figure>\n<\/figure>\n\n\n\n<p><strong>1.\ubaa8\ub4c8\uc124\uce58(install modules)<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\ud0ed \ub124\ube44\uac8c\uc774\ud130\ub97c \uc0ac\uc6a9\ud558\uae30 \uc704\ud574\uc11c\ub294 \ubaa8\ub4c8\uc744 \uc124\uce58\ud574\uc57c \ud569\ub2c8\ub2e4<br>To use the tab navigator, you need to install the module<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\ud0ed \ub124\ube44\uac8c\uc774\ud130\ub97c \uc704\ud574 \uc124\uce58\ud574\uc57c \ud558\ub294 \ubaa8\ub4c8\uc740 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<br>The modules you need to install for the tab navigator are:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>@react-navigation\/bottom-tabs\n@react-navigation\/native\nreact-native-safe-area-context\nreact-native-screens<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>@react-navigation\/bottom-tabs \uc774 \ubaa8\ub4c8\uc774 \ud0ed \ub124\ube44\uac8c\uc774\ud130 \ubaa8\ub4c8\uc785\ub2c8\ub2e4.<br>&#8220;@react-navigation\/bottom-tabs &#8221; This module is the tab navigator module.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\ub098\uba38\uc9c0 \ubaa8\ub4c8\uc740 \ud0ed \ub124\ube44\uac8c\uc774\ud130\uc640 \uc9c1\uc811 \uad00\ub828\uc774 \uc5c6\uc9c0\ub9cc \uc124\uce58 \ud558\uc9c0 \uc54a\uc73c\uba74 \uc624\ub958\uac00 \ubc1c\uc0dd\ud569\ub2c8\ub2e4.<br>The remaining modules are not directly related to the tab navigator, but will cause errors if you don&#8217;t install them.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\uadf8\ub798\uc11c \ub098\uba38\uc9c0 \ubaa8\ub4c8\ub3c4 \ubc18\ub4dc\uc2dc \uc124\uce58\ud574\uc57c \ud569\ub2c8\ub2e4.<br>So, you must install the remaining modules as well.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\ud0ed\ub124\ube44\uac8c\uc774\ud130\uc5d0\ub294 \uc544\uc774\ucf58\uc774 \uc0ac\uc6a9\ub429\ub2c8\ub2e4. \uc544\uc774\ucf58\uc744 \uc704\ud55c \ubaa8\ub4c8\ub3c4 \uc124\uce58 \ud569\ub2c8\ub2e4.<br>Icons are used in the tab navigator. Also install modules for icons.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>react-native-vector-icons<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\uc774 \uc571\uc744 \uc2e4\ud589\ud558\uae30 \uc704\ud574\uc11c \uc0ac\uc6a9\ub418\ub294 \uc804\uccb4 \ubaa8\ub4c8 \uc785\ub2c8\ub2e4.<br>This is the entire module used to run this app.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"581\" height=\"191\" src=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/package_json.png\" alt=\"\" class=\"wp-image-962\" srcset=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/package_json.png 581w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/package_json-300x99.png 300w\" sizes=\"auto, (max-width: 581px) 100vw, 581px\" \/><\/figure>\n\n\n\n<p><strong>2.\ucf54\ub4dc \uc791\uc131 \/ Write cod<\/strong>e<br>-\uc774 \uc571\uc758 \ub514\ub809\ud1a0\ub9ac \uad6c\uc870\uc785\ub2c8\ub2e4.<br>This is the directory structure for this app<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"308\" height=\"531\" src=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/directory.png\" alt=\"\" class=\"wp-image-963\" srcset=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/directory.png 308w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/directory-174x300.png 174w\" sizes=\"auto, (max-width: 308px) 100vw, 308px\" \/><\/figure>\n\n\n\n<p>-App.js\ud30c\uc77c\uc5d0 \ub2e4\uc74c \ucf54\ub4dc\ub97c \uc791\uc131 \ud569\ub2c8\ub2e4.<br>Write the following code in the App.js file.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"593\" height=\"345\" src=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/App1_js-1.png\" alt=\"\" class=\"wp-image-965\" srcset=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/App1_js-1.png 593w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/App1_js-1-300x175.png 300w\" sizes=\"auto, (max-width: 593px) 100vw, 593px\" \/><\/figure>\n\n\n\n<p>-BottomTabNavigator.js\ud30c\uc77c\uc744 \ub9cc\ub4e4\uace0 \ub2e4\uc74c \ucf54\ub4dc\ub97c \uc791\uc131\ud569\ub2c8\ub2e4.<br>Create a BottomTabNavigator.js file and write the following code.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"595\" src=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/BottomTabNavigator_js.png\" alt=\"\" class=\"wp-image-966\" srcset=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/BottomTabNavigator_js.png 640w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/09\/BottomTabNavigator_js-300x279.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure>\n\n\n\n<p><strong>4.npm run android<\/strong><br>-npm run android\uba85\ub839\uc73c\ub85c \ub514\ubc84\uae45\uc744 \uc2e4\ud589\ud569\ub2c8\ub2e4.<br>Execute debugging with the &#8220;npm run android&#8221; command.<\/p>\n\n\n\n<p><strong>5.\uc804\uccb4 \ucf54\ub4dc(full code)<\/strong><\/p>\n\n\n\n<p>-\uc774\ubc88 \ud3ec\uc2a4\ud2b8\uc5d0\uc11c \uc124\uba85\ud558\uc9c0 \ubabb\ud55c \ubd80\ubd84\uc740 \ub2e4\uc74c \ud3ec\uc2a4\ud2b8\uc5d0\uc11c \uc124\uba85\ud558\uaca0\uc2b5\ub2c8\ub2e4.<br>Anything that was not explained in this post will be explained in the next post.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ App.js\n\nimport { NavigationContainer } from '@react-navigation\/native';\nimport * as React from 'react';\n\n\n\/\/ BottomTabNavigator.js file\nimport BottomTabNavigator from '.\/BottomTabNavigator';\n\nexport default function App() {\n  return (\n    &lt;NavigationContainer>\n      &lt;BottomTabNavigator \/>\n    &lt;\/NavigationContainer>\n  );\n  \n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ BottomTabNvigator.js\n\nimport { StatusBar,View,StyleSheet,Dimensions } from 'react-native';\n\n\/\/ Tab Navigator\nimport { createBottomTabNavigator } from '@react-navigation\/bottom-tabs';\n\n\/\/ Ionicons\n import Icon from 'react-native-vector-icons\/Ionicons';\n \/\/import Icon from 'react-native-vector-icons\/FontAwesome5';\n\n\/\/webview \nimport { WebView } from 'react-native-webview';\n\n\/\/ webview size\nconst windowWidth = Dimensions.get('window').width;\nconst windowHeight = Dimensions.get('window').height;\n\nconst Tab = createBottomTabNavigator();\n\nconst BottomTabNavigator = () =&gt; {\n  return (\n      &lt;Tab.Navigator screenOptions={{ headerShown: true }}&gt;\n        &lt;Tab.Screen name=\"Tab1\" component={Tab1} \n                  options={{\n                    tabBarLabel: 'Home',\n                    tabBarIcon: ({ color, size }) =&gt; (\n                    &lt;Icon name=\"home\" color={ color } size={ size } \/&gt;\n                    ),\n                  }} \n        \/&gt;\n        &lt;Tab.Screen name=\"Tab2\" component={Tab2}\n        \n                  options={{\n                    tabBarLabel: 'Tab2',\n                    tabBarIcon: ({ color, size }) =&gt; (\n                    &lt;Icon name=\"bag-add\" color={ color } size={ size } \/&gt;\n                    ),\n                  }} \n        \/&gt;        \n      &lt;\/Tab.Navigator&gt;\n  );\n}\nconst Tab1 = () =&gt; {\n    return (\n      &lt;View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}&gt;\n  \n        &lt;WebView style={styles.webview} \n          source={{ uri: 'https:\/\/freelifemakers.org' }} \n          allowsFullscreenVideo={true}\n          allowsInlineMediaPlayback={true}\n          javaScriptEnabled={true}\n          scalesPageToFit={true}\n          domStorageEnabled={true}\n          mediaPlaybackRequiresUserAction={false}\n        \/&gt;\n        &lt;StatusBar\n          barStyle=\"light-content\" \/\/ Options: 'default', 'light-content', 'dark-content'\n          backgroundColor=\"#6a51ae\" \/\/ For Android\n          hidden={false}            \/\/ Show or hide the status bar\n          translucent={true}        \/\/ Allow content to render under the status bar\n        \/&gt;\n        \n      &lt;\/View&gt;\n    );\n  }\n\nconst Tab2 = () =&gt; {\n  return (\n    &lt;View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}&gt;\n            \n      &lt;WebView style={styles.webview} \n               source={{ uri: 'https:\/\/freelifemakers.org\/lec\/list01.php' }} \n               allowsFullscreenVideo={true}\n               allowsInlineMediaPlayback={true}\n               javaScriptEnabled={true}\n               scalesPageToFit={true}\n               domStorageEnabled={true}\n               mediaPlaybackRequiresUserAction={false}\n      \/&gt;\n      &lt;StatusBar\n               barStyle=\"light-content\" \/\/ Options: 'default', 'light-content', 'dark-content'\n               backgroundColor=\"#6a51ae\" \/\/ For Android\n               hidden={false}            \/\/ Show or hide the status bar\n               translucent={true}        \/\/ Allow content to render under the status bar\n      \/&gt;\n\n    &lt;\/View&gt;\n  );\n}\n\n  \/\/ webview style\nconst styles = StyleSheet.create({\n  container: {\n    flex: 1,\n    alignItems: 'center',\n    \/\/justifyContent: 'space-between',\n    justifyContent: 'center',\n  },\n  \/\/ webview size\n  webview: {\n    flex: 1,\n    width: windowWidth,\n    height: windowHeight,\n  },\n});\n\nexport default BottomTabNavigator\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>-\ud0ed \ub124\ube44\uac8c\uc774\ud130\ub97c \uc0ac\uc6a9\ud558\ub294 \ubc29\ubc95\uc5d0 \ub300\ud55c \uc124\uba85\uc785\ub2c8\ub2e4.Here&#8217;s an explanation of how to use the tab navigator. -\ud0ed \ub124\ube44\uac8c\uc774\ud130\ub294 \uc571\uc5d0\uc11c \uc0ac\uc6a9\uac00\ub2a5\ud55c \uba54\ub274\uc758 \ud55c \uc885\ub958 \uc785\ub2c8\ub2e4.Tab navigator is a type of menu available in apps. -\ud0ed \ub124\ube44\uac8c\uc774\ud130\ub294 \uc571\uc758 \ud558\ub2e8\uc5d0 \ud0ed\uc744 \ud560\ub54c \ud654\uba74 \uc804\ud658\uc744 \ud560 \uc218 \uc788\ub3c4\ub85d \ub3c4\uc640\uc90d\ub2c8\ub2e4.The tab navigator helps you switch screens when you tap at the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,1],"tags":[],"class_list":["post-957","post","type-post","status-publish","format-standard","hentry","category-reactnative","category-uncategorized","missing-thumbnail"],"_links":{"self":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/957","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=957"}],"version-history":[{"count":4,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/957\/revisions"}],"predecessor-version":[{"id":970,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/957\/revisions\/970"}],"wp:attachment":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}