Since StatelessComponent
is deprecated, I am trying to turn all the components into classes.
I have an interface, for example:
interface MyInterface{
prop1: number;
prop2: boolean;
}
And I use it in the class:
class MyComponent extends React.Component<MyInterface> {
...
public render(){...}
}
And when I try to use MyComponent
like this:
<MyComponent
prop1={3}
prop2={false}
/>
I get this error:
TS2740: Type {prop1: 3, prop2: false} is missing the following properties from type ReadOnly: render, context, setState, forceUpdate, and 3 more.
Is there any workaround to this?