inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

임홍진님의 게시글

임홍진 임홍진

@bluechippush1470

수강평 작성수
-
평균평점
-

게시글 1

질문&답변

Type '({ navigation }: HomeScreenProps) => Element' is not assignable to type 'ScreenComponentType<ParamListBase, "Home"> | undefined'. 에러

@react-navigation/core@6.2.2 버전이어도 같은 에러라서 겉핧기지만 공부했습니다. Type '({ navigation }: HomeScreenProps) => Element' is not assignable to type 'ScreenComponentType | undefined'. navigation 의 요소는 ScreenComponentType에 맞지 않는다는 의미인것같고 강의 소스에서 navigation에 지정(?)된 타입은 NativeStackScreenProps 입니다. NativeStackScreenProps을 tpyes.d.ts에서보면 NativeStackScreenProps 으로 지정된 타입안에서도 navigation이나 route는 세부 type으로 지칭되어야 하는것으로 보여집니다. 그래서 navigation 전환만 하는 페이지의 type 선언을 NativeStackScreenProps -> NativeStackNavigationProp으로 변경하고 RN navigation 공식문서의 Annotating useNavigation을 참고했더니 고쳐졌습니다. https://reactnavigation.org/docs/typescript/#type-checking-screens

좋아요수
0
댓글수
3
조회수
2903