Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6208

Why does this.props.onLayout not exist for my React Native component?

$
0
0

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?


Viewing all articles
Browse latest Browse all 6208

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>