withNavigationFocus引发皮棉错误-React Native Typescript

时间:2020-02-24 05:15:31

标签: typescript react-native ecmascript-6 types react-navigation

我正在尝试将NavigationFocus用于组件,因为代码是用Typescript编写的。 ,

我的道具道具

   interface IScreenProps {
  navigation: NavigationScreenProp<NavigationState, IParamsNavigate>;
  departments: NavigationNode[] | null;
  updateSearchCriteria: (searchCriteria: ISearchCriteria, stack: StackNames) => void;
  resetProductState: () => void;
  isFocused: boolean;
}

组件

class SearchScreen extends React.Component<IScreenProps, IScreenState> {

.....

}

export default connect(mapStateToProps, mapDispatchToProps)( withNavigationFocus(SearchScreen));

没有构建错误,在searchScreen导出时,编辑器/ IDE中仍以红线显示。我遇到了下面的错误。

enter image description here

请让我知道如何解决此问题。

1 个答案:

答案 0 :(得分:0)

使用NavigationStackProp(或与您的导航器相关的一种),而不是NavigationScreenProp

interface IScreenProps {
  navigation: NavigationStackProp<IParamsNavigate>;
  departments: NavigationNode[] | null;
  updateSearchCriteria: (searchCriteria: ISearchCriteria, stack: StackNames) => void;
  resetProductState: () => void;
  isFocused: boolean;
}

https://reactnavigation.org/docs/en/4.x/typescript.html