{"id":996,"date":"2024-11-04T10:01:39","date_gmt":"2024-11-04T10:01:39","guid":{"rendered":"https:\/\/www.freelifemakers.org\/wordpress\/?p=996"},"modified":"2024-11-04T10:23:03","modified_gmt":"2024-11-04T10:23:03","slug":"reactnativedrawer-layout","status":"publish","type":"post","link":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/2024\/11\/04\/reactnativedrawer-layout\/","title":{"rendered":"[ReactNative]Drawer Layout"},"content":{"rendered":"\n<p>\uc544\ub798\ub294 Drawer Layout\uad00\ub828 \ucf54\ub4dc \uc785\ub2c8\ub2e4.<br>Below is the code related to Drawer Layout.<\/p>\n\n\n\n<p>\uc774\ubbf8 \uba54\ub274\uc5bc\uc774 \uc788\uc9c0\ub9cc \uc9c1\uc811 \uba54\ub274\uc5bc\ubcf4\uace0 \ub530\ub77c\ud574\ubcf4\uba74 \uc2e4\ud589\ub418\uc9c0 \uc54a\ub294 \uacbd\uc6b0\uac00 \uc788\uc2b5\ub2c8\ub2e4.<br>There is already a manual, but if you try to read the manual and follow it, it may not work.<\/p>\n\n\n\n<p>\uc544\ub798\ub294 \ucf54\ub4dc\ub294 \uc81c\uac00 \ud14c\uc2a4\ud2b8 \ud588\uc744\ub54c \uc815\uc0c1 \uc791\ub3d9\ud558\ub294 \ucf54\ub4dc \uc785\ub2c8\ub2e4.<br>Below is the code that works properly when I tested it.<\/p>\n\n\n\n<p><strong>package.json<\/strong><\/p>\n\n\n\n<p>module install : <a href=\"https:\/\/docs.swmansion.com\/react-native-reanimated\/docs\/fundamentals\/getting-started\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/docs.swmansion.com\/react-native-reanimated\/docs\/fundamentals\/getting-started\/<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"name\": \"App1\",\n  \"version\": \"0.0.1\",\n  \"private\": true,\n  \"scripts\": {\n    \"android\": \"react-native run-android\",\n    \"ios\": \"react-native run-ios\",\n    \"lint\": \"eslint .\",\n    \"start\": \"react-native start\",\n    \"test\": \"jest\"\n  },\n<strong>  \"dependencies\": {\n    \"@react-native-community\/masked-view\": \"^0.1.11\",\n    \"@react-navigation\/drawer\": \"^6.7.2\",\n    \"@react-navigation\/native\": \"^6.1.18\",\n    \"react\": \"18.3.1\",\n    \"react-native\": \"0.75.3\",\n    \"react-native-gesture-handler\": \"^2.19.0\",\n    \"react-native-reanimated\": \"^3.15.2\",\n    \"react-native-s<\/strong>afe-area-context\": \"^4.11.0\",\n    \"react-native-screens\": \"^3.34.0\"\n  },\n  \"devDependencies\": {\n    \"@babel\/core\": \"^7.20.0\",\n    \"@babel\/preset-env\": \"^7.20.0\",\n    \"@babel\/runtime\": \"^7.20.0\",\n    \"@react-native\/babel-preset\": \"0.75.3\",\n    \"@react-native\/eslint-config\": \"0.75.3\",\n    \"@react-native\/metro-config\": \"0.75.3\",\n    \"@react-native\/typescript-config\": \"0.75.3\",\n    \"@types\/react\": \"^18.2.6\",\n    \"@types\/react-test-renderer\": \"^18.0.0\",\n    \"babel-jest\": \"^29.6.3\",\n    \"eslint\": \"^8.19.0\",\n    \"jest\": \"^29.6.3\",\n    \"prettier\": \"2.8.8\",\n    \"react-test-renderer\": \"18.3.1\",\n    \"typescript\": \"5.0.4\"\n  },\n  \"engines\": {\n    \"node\": \"&gt;=18\"\n  }\n}\n<\/code><\/pre>\n\n\n\n<p><strong>babel.config.js<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>module.exports = {\n  presets: &#91;'module:@react-native\/babel-preset'],\n  <strong>plugins: &#91;'react-native-reanimated\/plugin']<\/strong>,\n};\n<\/code><\/pre>\n\n\n\n<p><strong>index.js<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @format\n *\/\n\nimport {AppRegistry} from 'react-native';\nimport App from '.\/App';\nimport {name as appName} from '.\/app.json';\n\nAppRegistry.registerComponent(appName, () =&gt; App);<\/code><\/pre>\n\n\n\n<p><strong>App.js<\/strong>( test code : <a href=\"https:\/\/reactnavigation.org\/docs\/drawer-based-navigation\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/reactnavigation.org\/docs\/drawer-based-navigation\/<\/a>)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import * as React from 'react';\nimport { Button, View } from 'react-native';\nimport { createDrawerNavigator } from '@react-navigation\/drawer';\nimport { NavigationContainer } from '@react-navigation\/native';\n\nfunction HomeScreen({ navigation }) {\n  return (\n    &lt;View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}&gt;\n      &lt;Button\n        onPress={() =&gt; navigation.navigate('Notifications')}\n        title=\"Go to notifications\"\n      \/&gt;\n    &lt;\/View&gt;\n  );\n}\n\nfunction NotificationsScreen({ navigation }) {\n  return (\n    &lt;View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}&gt;\n      &lt;Button onPress={() =&gt; navigation.goBack()} title=\"Go back home\" \/&gt;\n    &lt;\/View&gt;\n  );\n}\n\nconst Drawer = createDrawerNavigator();\n\nexport default function App() {\n  return (\n    &lt;NavigationContainer&gt;\n      &lt;Drawer.Navigator initialRouteName=\"Home\"&gt;\n        &lt;Drawer.Screen name=\"Home\" component={HomeScreen} \/&gt;\n        &lt;Drawer.Screen name=\"Notifications\" component={NotificationsScreen} \/&gt;\n      &lt;\/Drawer.Navigator&gt;\n    &lt;\/NavigationContainer&gt;\n  );\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\uc544\ub798\ub294 Drawer Layout\uad00\ub828 \ucf54\ub4dc \uc785\ub2c8\ub2e4.Below is the code related to Drawer Layout. \uc774\ubbf8 \uba54\ub274\uc5bc\uc774 \uc788\uc9c0\ub9cc \uc9c1\uc811 \uba54\ub274\uc5bc\ubcf4\uace0 \ub530\ub77c\ud574\ubcf4\uba74 \uc2e4\ud589\ub418\uc9c0 \uc54a\ub294 \uacbd\uc6b0\uac00 \uc788\uc2b5\ub2c8\ub2e4.There is already a manual, but if you try to read the manual and follow it, it may not work. \uc544\ub798\ub294 \ucf54\ub4dc\ub294 \uc81c\uac00 \ud14c\uc2a4\ud2b8 \ud588\uc744\ub54c \uc815\uc0c1 \uc791\ub3d9\ud558\ub294 \ucf54\ub4dc \uc785\ub2c8\ub2e4.Below is the code that works [&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-996","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\/996","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=996"}],"version-history":[{"count":5,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/996\/revisions"}],"predecessor-version":[{"id":1002,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/996\/revisions\/1002"}],"wp:attachment":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=996"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=996"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=996"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}