{"id":971,"date":"2024-09-09T09:39:32","date_gmt":"2024-09-09T09:39:32","guid":{"rendered":"https:\/\/www.freelifemakers.org\/wordpress\/?p=971"},"modified":"2024-09-09T12:21:55","modified_gmt":"2024-09-09T12:21:55","slug":"reactnative-tab-navigator-code-explanation","status":"publish","type":"post","link":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/2024\/09\/09\/reactnative-tab-navigator-code-explanation\/","title":{"rendered":"[ReactNative]Tab navigator \ucf54\ub4dc\uc124\uba85 \/ Tab navigator code explanation"},"content":{"rendered":"\n<p>\uc774 \ud3ec\uc2a4\ud2b8\ub294 Tab navigator\uc0ac\uc6a9\ud558\uae30\uc5d0 \ub300\ud55c \ucf54\ub4dc \uc124\uba85\uc785\ub2c8\ub2e4.<br>This post is a code explanation for using the Tab navigator.<\/p>\n\n\n\n<p>\ud55c\ubc88 \ubcf4\uc2dc\uba74 \ud06c\uac8c \uc774\ud574\ud558\uae30 \uc5b4\ub824\uc6b4 \ubd80\ubd84\uc740 \uc5c6\ub2e4\uace0 \uc0dd\uac01\ub429\ub2c8\ub2e4.<br>If you take a look, I don&#8217;t think there is anything that is very difficult to understand.<\/p>\n\n\n\n<p>\uc774\uc804\ud3ec\uc2a4\ud2b8(previous post)<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/2024\/09\/05\/reactnative-using-tab-navigator\/\" data-type=\"URL\" data-id=\"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/2024\/09\/05\/reactnative-using-tab-navigator\/\" target=\"_blank\">[ReactNative]\ud0ed\ub124\ube44\uac8c\uc774\ud130 \uc0ac\uc6a9\ud558\uae30 \/ Using Tab Navigator<\/a><\/p>\n\n\n\n<p><strong>1.App.js<\/strong><br>-\uc124\uce58\ud55c \ubaa8\ub4c8\uc744 \ucd94\uac00\ud558\ub294 \ubd80\ubd84\uc785\ub2c8\ub2e4.<br>This is the part where you add the installed module.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { NavigationContainer } from '@react-navigation\/native';\nimport * as React from 'react';<\/code><\/pre>\n\n\n\n<p>-\ucf54\ub4dc\ub97c BottomTabNavigator.js\ud30c\uc77c\ub85c \ub9cc\ub4e4\uc5b4\uc11c \ud638\ucd9c\ud569\ub2c8\ub2e4.<br>Create the code in the BottomTabNavigator.js file and call it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import BottomTabNavigator from '.\/BottomTabNavigator';<\/code><\/pre>\n\n\n\n<p>BottomTabNavigator\ud568\uc218\ub97c \uc2e4\ud589\ud569\ub2c8\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>export default function App() {\n  return (\n    &lt;NavigationContainer&gt;\n      &lt;BottomTabNavigator \/&gt;\n    &lt;\/NavigationContainer&gt;\n  );\n}\n<\/code><\/pre>\n\n\n\n<p><strong>2.BottomTabNavigator.js<\/strong><\/p>\n\n\n\n<p>-\uc124\uce58\ud55c \ubaa8\ub4c8\uc744 \ucd94\uac00\ud558\ub294 \ubd80\ubd84\uc785\ub2c8\ub2e4.<br>his is the part where you add the installed module.<\/p>\n\n\n\n<p>-\uc544\uc774\ucf58\uc740 Ionicons,FontAwesome\uc678\uc5d0\ub3c4 \ub2e4\ub978 \uc544\uc774\ucf58\uc744 \uc0ac\uc6a9 \ud560 \uc218\ub3c4 \uc788\uc2b5\ub2c8\ub2e4.<br>You can also use icons other than Ionicons and FontAwesome.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.npmjs.com\/package\/react-native-vector-icons\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.npmjs.com\/package\/react-native-vector-icons<\/a><br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { 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';<\/code><\/pre>\n\n\n\n<p>-\ud0ed\ub124\ube44\uac8c\uc774\ud130\ub97c \uc0dd\uc131\ud558\ub294 \ubd80\ubd84\uc785\ub2c8\ub2e4.<br>This is the part that creates the tab navigator.<\/p>\n\n\n\n<p>{Tab1}\uc740 const Tab1 = () =&gt;{ } \ud568\uc218\ub97c \uc758\ubbf8\ud569\ub2c8\ub2e4.<br>{Tab1} means &#8220;const Tab1 = () =&gt; { }&#8221; function.<\/p>\n\n\n\n<p>{Tab2}\ub294 const Tab2 = () =&gt; { } \ud568\uc218\ub97c \uc758\ubbf8\ud569\ub2c8\ub2e4.<br>{Tab2} means &#8220;const Tab2 = () =&gt; { }&#8221;  function.<\/p>\n\n\n\n<p>options\uc601\uc5ed\uc5d0\ub294 \ud0ed\ubc14 \ub77c\ubca8\uacfc \uc544\uc774\ucf58\uc5d0 \ub300\ud55c \uc124\uc815\uc785\ub2c8\ub2e4.<br>The options area contains settings for the tab bar label and icon.<\/p>\n\n\n\n<p>-Icon &#8220;Home&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;Icon name=\"home\" color={ color } size={ size } \/&gt;<\/code><\/pre>\n\n\n\n<p>-Icon &#8220;bag-add&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;Icon name=\"bag-add\" color={ color } size={ size } \/&gt;<\/code><\/pre>\n\n\n\n<p>-BottomTabNavigator<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\nconst Tab = createBottomTabNavigator();\nconst BottomTabNavigator = () =&gt; {\n  return (\n      &lt;Tab.Navigator screenOptions={{ headerShown: true }}&gt;\n        &lt;Tab.Screen <strong>name=\"Tab1\"<\/strong> <strong>component={Tab1} <\/strong>\n                  options={{\n                    <strong>tabBarLabel: 'Home',<\/strong>\n                    tabBarIcon: ({ color, size }) =&gt; (\n                    <strong>&lt;Icon name=\"home\" color={ color } size={ size } \/&gt;<\/strong>\n                    ),\n                  }} \n        \/&gt;\n        &lt;Tab.Screen <strong>name=\"Tab2\"<\/strong> <strong>component={Tab2}<\/strong>\n        \n                  options={{\n                    <strong>tabBarLabel: 'Tab2',<\/strong>\n                    tabBarIcon: ({ color, size }) =&gt; (\n                    <strong>&lt;Icon name=\"bag-add\" color={ color } size={ size } \/&gt;<\/strong>\n                    ),\n                  }} \n        \/&gt;        \n      &lt;\/Tab.Navigator&gt;\n  );\n}\n<\/code><\/pre>\n\n\n\n<p><strong>3.\uc804\uccb4\ucf54\ub4dc(full code)<\/strong><\/p>\n\n\n\n<p>-App.js<\/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&gt;\n      &lt;BottomTabNavigator \/&gt;\n    &lt;\/NavigationContainer&gt;\n  );\n  \n}\n<\/code><\/pre>\n\n\n\n<p>-BottomTabNavigator.js<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ App1\/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<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\uc774 \ud3ec\uc2a4\ud2b8\ub294 Tab navigator\uc0ac\uc6a9\ud558\uae30\uc5d0 \ub300\ud55c \ucf54\ub4dc \uc124\uba85\uc785\ub2c8\ub2e4.This post is a code explanation for using the Tab navigator. \ud55c\ubc88 \ubcf4\uc2dc\uba74 \ud06c\uac8c \uc774\ud574\ud558\uae30 \uc5b4\ub824\uc6b4 \ubd80\ubd84\uc740 \uc5c6\ub2e4\uace0 \uc0dd\uac01\ub429\ub2c8\ub2e4.If you take a look, I don&#8217;t think there is anything that is very difficult to understand. \uc774\uc804\ud3ec\uc2a4\ud2b8(previous post) [ReactNative]\ud0ed\ub124\ube44\uac8c\uc774\ud130 \uc0ac\uc6a9\ud558\uae30 \/ Using Tab Navigator 1.App.js-\uc124\uce58\ud55c \ubaa8\ub4c8\uc744 \ucd94\uac00\ud558\ub294 \ubd80\ubd84\uc785\ub2c8\ub2e4.This is 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-971","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\/971","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=971"}],"version-history":[{"count":9,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/971\/revisions"}],"predecessor-version":[{"id":984,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/971\/revisions\/984"}],"wp:attachment":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}