I have the following class in my React Native app (using Typescript):
class Component1 extends React.Component<IntroProps, {}> {
constructor(props){
super(props)
console.log(props.onLayout)
}
...
}
I read in the documentation on the View
class that any View
or component that inherits from it have this.props.onLayout
. However, this logs undefined
, and if I use this.props.onLayout
instead of props.onLayout
, it gives the warning "Property 'onLayout' does not exist on type 'Readonly & Readonly<{ children?: ReactNode;>'".
I've seen other examples of people using this.props.onLayout
in their component similar to mine, except that mine uses TypeScript.
What I Want To Know:
Why can't I access this.props.onLayout
here, and how can I access it?