๐Ÿ’ป[React Native] Stack Navigation UI

ํ˜ฑยท2023๋…„ 1์›” 23์ผ

๐Ÿ“Œ Header ์—†์• ๊ธฐ

DefaultStackNavigator.js

 <Stack.Screen
          name={'BoxOffice'}
          component={BoxOffice}
          options={{headerShown: false}} //๊ธฐ๋ณธ๊ฐ’: true
        />

๐Ÿ“Œ Header ๋ง˜๋Œ€๋กœ ์ง€์ •ํ•˜๊ธฐ

๊ฐ ํŽ˜์ด์ง€ SCREEN ํŒŒ์ผ์—์„œ setOptions๋ฅผ ํ†ตํ•ด ์ง€์ •

MovieDetails.js

  useEffect( //๊ฐ title์ด ๋ฐ”๋€” ๋•Œ๋งˆ๋‹ค ๋ Œ๋”๋ง๋˜์–ด์•ผ ํ•˜๋ฏ€๋กœ,,,
    ((effect = () => {
      if (data) { //data๊ฐ€ ์žˆ์œผ๋ฉด
        navigation.setOptions({
          title: detail.movieNm,
        });
      }
    }),
    (deps = [data])),
  );

Header๊ฐ€ ์žˆ๋‹ค๋ฉด SafeAreaView๊ฐ€ ์ž๋™์œผ๋กœ ์„ ํƒ๋œ ์ƒํƒœ์ž„!

๐Ÿ“Œ ๋ชจ๋“  Screens์— ๋Œ€ํ•œ option

screenOptions ํ™œ์šฉ

DefaultStackNavigator.js

   <Stack.Navigator screenOptions={{headerShown: false}}>
        <Stack.Screen
          name={'BoxOffice'}
          component={BoxOffice}
          options={{headerShown: false}}
        />
        <Stack.Screen name={'MovieDetail'} component={MovieDetail} />
        <Stack.Screen name={'SearchResult'} component={SearchResult} />
      </Stack.Navigator>
profile
new blog: https://hae0-02ni.tistory.com/

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