I'm trying to access props
of a React [Native] component in my app (which are guaranteed to be instance of element of my custom type ItemTemplate
:
const children = React.Children.toArray(this.props.children);
return children.find(t => t.props.itemKey == key);
However, in the second line when I try to access t.props
I'm getting:
Property 'props' does not exist on type 'ReactElement<ItemTemplate, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)> | ... 13 more ... | (ReactElement<...>[] & ReactPortal)'.
Property 'props' does not exist on type 'ReactElement<ItemTemplate, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)>[] & string'.
The code does work correctly, but TypeScript (3.6.3) IntelliSense is complaining. Why?