Hỏi & Đáp
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
- Lượt thích
- 0
- Số bình luận
- 3
- Lượt xem
- 2899

