1์›” 4์ผ TIL

jiniยท2023๋…„ 1์›” 3์ผ
0

TIL๐ŸŒฑ

๋ชฉ๋ก ๋ณด๊ธฐ
56/95
post-thumbnail

Today I Learned ๐Ÿ“–

react native ์‹ฌํ™” ๋ณต์Šต

1)App icon, Splash Screen ์ด๋ฏธ์ง€ ๋ณ€๊ฒฝ

App icon -> ํ”ผ๊ทธ๋งˆ๋งํฌ : ํ”ผ๊ทธ๋งˆ์—์„œ ๊ฐ ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์ €์žฅํ•ด์„œ assetsํŒŒ์ผ์— ๋ณต๋ถ™ํ•˜๋ฉด ๋ !

2) React Navigation - Bottom Tab Navigator

App.js์—๋Š” ์ปดํฌ๋„ŒํŠธ๋งŒ ๋‚จ๊ฒจ์ค€๋‹ค.
๋„ค๋น„๊ฒŒ์ด์…˜์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ํ•ด๋‹น ์ปดํฌ๋„ŒํŠธ๋ฅผ ์•„๋ž˜์™€ ๊ฐ™์ด ๊ฐ์‹ธ์ค€๋‹ค.

<NavigationContainer>
  <Tabs /> 
</NavigationContainer>

์—ฌ๊ธฐ์„œ Tabs๋Š” BottomTab๋„ค๋น„๊ฐ€ ๋“ค์–ด๊ฐ€๋Š” ์ปดํฌ๋„ŒํŠธ!!

Bottom Tab Navigator ๋„ค๋น„๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ ๊ธฐ๋ณธ ์„ค์น˜๋ฅผ ํ•ด์ฃผ๊ณ , ์ž„ํฌํŠธ๋„ ํ•ด์ฃผ๊ธฐ.

๋„ค๋น„๊ฒŒ์ดํ„ฐ์— ์˜ต์…˜์„ ์ค„๋•Œ๋Š”,
Tab.navigator -> screenOptions
Tab.Screen -> options

//Tab.Screen์—์„œ ์•„์ด์ฝ˜ ๋ณ€๊ฒฝํ•ด์ค„๋•Œ, 
options={{
          tabBarIcon: ({ color, size }) => (
            <MaterialIcons name="movie-filter" size={size} color={color} />
          ),
        }}

4)React Navigation๋ณ‘ํ•ฉ

RootํŒŒ์ผ์„ ๋งŒ๋“ค์–ด Stacks.js/Tabs.js๋ฅผ ๋ณ‘ํ•ฉํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  App.jsํŒŒ์ผ์—์„œ Root.js์ž„ํฌํŠธํ•˜๊ธฐ -> BottomTabNavigator์˜ ์Šคํฌ๋ฆฐ์ธ Movies.js์— ๊ฐ€์„œ NativeStackNavigator๋ฅผ ๋ถˆ๋Ÿฌ์™€์ค€๋‹ค.

<TouchableOpacity
   onPress={() => navigate("Stacks", { screen: "one"})}> 
     <Text>Detail</Text>
</TouchableOpacity>

(9) Movies ์Šคํฌ๋ฆฐ UI ์™„์„ฑ

์˜ค๋Š˜์˜ ์—๋Ÿฌ๐Ÿ› 

Text strings must be rendered within a <Text> component.

ํ…์ŠคํŠธ๊ฐ€ ๋‚˜์™€์•ผํ•˜๋Š” ๋ถ€๋ถ„์—์„œ ํ…์ŠคํŠธ ์‚ฌ์šฉ์„ ์•ˆํ•ด์ฃผ๋‹ˆ ๊ณ„์† ๋œจ๋Š” ์˜ค๋ฅ˜,, ํ…์ŠคํŠธ ๋„ฃ์–ด์ฃผ๊ธฐ !

profile
๐ŸŒฑ

0๊ฐœ์˜ ๋Œ“๊ธ€