Skip to content

9.5.3 프로필 화면 > 헤더 변경 작업 이후 나타나는 경고 #26

Answered by Alchemist85K
Choiguevara88 asked this question in Q&A
Discussion options

You must be logged in to vote

안녕하세요 @Choiguevara88

route의 state에 직접 접근해서 발생하는 경고메시지 입니다.
리액트 내비게이션에서 제공하는 getFocusedRouteNameFromRoute를 이용하는 코드로 변경하면 해결할 수 있습니다.

+ 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 }}
             …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Choiguevara88
Comment options

Answer selected by Alchemist85K
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants