DEV Community

Sai Avinash Duddupudi
Sai Avinash Duddupudi

Posted on

Property 'maxCount' does not exist on type 'IntrinsicAttributes

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>'
Enter fullscreen mode Exit fullscreen mode

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;
Enter fullscreen mode Exit fullscreen mode

Top comments (4)

Collapse
 
lostintheway profile image
lostintheway

update antd to 4.14.0 or latest to use maxCount

Collapse
 
saiavinashiitr profile image
Sai Avinash Duddupudi

@lostintheway Thanks. I updated the version and it worked

Collapse
 
saiavinashiitr profile image
Sai Avinash Duddupudi

@coulis1018 max={1} is not working

Collapse
 
coulis1018 profile image
coulis1018

You can use 'max={1}', not maxCout