I am trying to implement antd upload button functionality in tsx file but for some reason I am getting the following Typescript error.
I have also created an interface for the same but no luck. Please suggest me where I am doing it wrong. Thanks
Type '{ children: Element; maxCount: number; }' is not assignable to type 'IntrinsicAttributes & UploadProps<any> & { children?: ReactNode; } & RefAttributes<any>'.
Property 'maxCount' does not exist on type 'IntrinsicAttributes & UploadProps<any> & { children?: ReactNode; } & RefAttributes<any>'
Here is the code
interface IMyProps {
maxCount: number,
}
const AdminPage: React.FC<IMyProps> = ({maxCount}) => {
const [isModalVisible, setIsModalVisible] = useState(false);
const onFinish = (values:any) => {
console.log(values)
};
return (
<React.Fragment>
<div>
<Modal title="Create" visible={isModalVisible} footer={null} onCancel={()=>setIsModalVisible(false)}>
<Form layout="vertical" onFinish={onFinish}>
<Form.Item label="Upload" name="uploading" >
<Upload maxCount={1}> <---------------- GETTING ERROR HERE
<Button icon={<UploadOutlined />}>Click to Upload</Button>
</Upload>
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit">
Submit
</Button>
</Form.Item>
</Form>
</Modal>
</div>
</React.Fragment>
)
}
export default AdminPage;
Top comments (4)
update antd to 4.14.0 or latest to use maxCount
@lostintheway Thanks. I updated the version and it worked
@coulis1018 max={1} is not working
You can use 'max={1}', not maxCout