How should I do something like
class App extends React.Component {
render() {
const { x, y, z} = this.props;
return (...)
}
}
in TypeScript? For now tslinter shows an Error:
Type 'Readonly<{ children?: ReactNode; }> & Readonly<{}>' has no property 'x' and no string index signature.
You have to define a type for props:
interface Props {
x: string;
y: number;
z: string;
}
class App extends React.Component<Props, {}> {
render() {
const { x, y, z} = this.props;
return (...)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With