I am encountering an issue with a specific package setup:
"react-navigation": "2.18.2",
"@types/react-navigation": "2.13.0",
"typescript": "3.1.6",
The problem arises when attempting to utilize the withNavigation
higher-order component in a child component, causing the parent component to flag missing required props. For example:
In the parent component:
render() {
return (
<Child
someProp={true}
/>
);
}
In the child component:
export interface IChildProps {
someProp: boolean
}
class Child extends React.Component<IChildProps & NavigationInjectedProps> {
render() {
return (<Text>Child component </Text>)
}
}
export default withNavigation(Child)
The error received in the parent component is:
Property 'navigation' is missing in type ...
, which suggests that the parent is unable to recognize that navigation
is being provided to the child through the withNavigation
HOC for unknown reasons?
One potential solution would involve manually passing down the navigation
prop from the parent, although this workaround defeats the purpose of using withNavigation
and merely shifts the issue further up the ancestor chain :smiley:
After reviewing the type definitions, I have not identified any discrepancies. Would anyone be able to offer insight into resolving this perplexing dilemma?