Why would this throw the error below?
export default class DeleteModal extends React.Component<DeleteModalProps, void>
Error:
Type 'void' is not assignable to type 'Readonly<{}>'
Why would this throw the error below?
export default class DeleteModal extends React.Component<DeleteModalProps, void>
Error:
Type 'void' is not assignable to type 'Readonly<{}>'
If we don't need state in the component, don't assign it would be fine.
React.Component<Props>
You can also set the empty object
interface State {}
React.Component<Props, State>
React.Component index.d.tsinterface Component<P = {}, S = {}, SS = any> extends ComponentLifecycle<P, S, SS> { }
You can see that it's been defined as empty Object {}
Declaring variables of type void is not useful because you can only assign
nullorundefinedto them
That's the reason for that error.