withNavigationFocus引发皮棉错误-React Native Typescript

问题描述 投票:0回答:1

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

我的道具

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

component

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

.....

}

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

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

enter image description here

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

typescript react-native ecmascript-6 types react-navigation
1个回答
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

© www.soinside.com 2019 - 2024. All rights reserved.