I describe HOC as in this article: https://medium.com/@jrwebdev/react-higher-order-component-patterns-in-typescript-42278f7590fb
My code (HOC):
import * as React from 'react';
import Dropzone from 'react-dropzone'
export const addImage = <P extends object>(WrappedComponent: React.ComponentType<P>) => {
return class extends React.Component {
render() {
return <Dropzone noClick onDrop={()=>{console.log('drop')}}>
{({ getRootProps, getInputProps }) => (
<div {...getRootProps()} onClick={()=>{console.log('aa')}}>
<input {...getInputProps()} />
<WrappedComponent {...this.props} />;
</div>
)}
</Dropzone>
}
};
}
In other component:
addImage(<Img src={item} />)
In HOC error: '{ children?: ReactNode; }' is assignable to the constraint of type 'P', but 'P' could be instantiated with a different subtype of constraint 'object'
How to fix the error?