9.5.3 프로필 화면 > 헤더 변경 작업 이후 나타나는 경고 #26
Answered
by
Alchemist85K
Choiguevara88
asked this question in
Q&A
-
src/navigations/MainTakb.js 의 MainTab 컴포넌트에 route 관련 내용을 추가하는 코드를 작업하고 나니, |
Beta Was this translation helpful? Give feedback.
Answered by
Alchemist85K
Mar 16, 2021
Replies: 1 comment 1 reply
-
안녕하세요 @Choiguevara88 route의 state에 직접 접근해서 발생하는 경고메시지 입니다. + import { getFocusedRouteNameFromRoute } from '@react-navigation/native'; - const titles = route.state?.routeNames || ['Channels'];
- const index = route.state?.index || 0;
+ const screenName = getFocusedRouteNameFromRoute(route) || 'Channels';
navigation.setOptions({
- headerTitle: titles[index],
+ headerTitle: screenName,
headerRight: () =>
- index === 0 && (
+ screenName === 'Channels' && (
<MaterialIcons
name="add"
size={26}
style={{ margin: 10 }}
onPress={() => navigation.navigate('Channel Creation')}
/>
),
}); 감사합니다. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Alchemist85K
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
안녕하세요 @Choiguevara88
route의 state에 직접 접근해서 발생하는 경고메시지 입니다.
리액트 내비게이션에서 제공하는
getFocusedRouteNameFromRoute
를 이용하는 코드로 변경하면 해결할 수 있습니다.+ import { getFocusedRouteNameFromRoute } from '@react-navigation/native';