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

Type a property/variable that accepts the ref of a component?

$
0
0

I want to type this.engine property with GameEnginesomething like, engine: GameEngine;and but it causes error Property 'stop' does not exist on type 'GameEngine'when using a GameEnginestop() method like below

Is this even possible? Or does it make sense?

export default class Game extends React.PureComponent {  engine: GameEngine;  // engine: any; // this one works ofcourse  //...  pause() {    this.engine.stop()  }  render() {    return (<GameEngine        ref={(ref) => { this.engine = ref; }}      />    )  }}

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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