I decided to convert my ReactNative project to TypeScript. I'm new to TypeScript and am finding it hard to fix this problem with custom components and inheritance. This is my (scaled down) code
import React, { Component } from "react";
import { Button, View } from "react-native";
interface IMyComponentProps extends React.Props<IMyComponentProps> {
colWidth?: number;
}
class MyComponent extends Component<IMyComponentProps> {
getProps() {
return this.props;
}
}
class MyButton extends MyComponent {
render() {
return (
<View {...this.getProps()}>
<Button title={this.props.title} onPress={this.props.onPress} />
</View>
);
}
}
I'm getting a red underline on ...this.getProps() in the MyButton component. Also this.props.title and this.props.onPress are not being identified.
Can you please help me with the types I need to define for these two classes.
Thanks