'React, ANTD: onChange called twice

ANTD Upload.Dragger called twice onChange function. I have no idea what should I do, because I tried many variants what I thought can help.

<Item
                    name='mainImage'
                    rules={getRule('Main Image', 'mainImage')}
                  >
                    <Dragger
                      accept='image/png, image/jpeg, image/svg, image/gif'
                      customRequest={onSuccess}
                      onChange={onFileChanged}
                      style={stylesDragger}
                      maxCount={1}
                    >
                      <div className='ant-upload-drag-icon'>
                        <CloudUploadOutlined size={20} />
                      </div>
                      <div className='ant-upload-text'><span>Click to upload</span> or drag and drop</div>
                      <div className='ant-upload-hint'>
                        SVG, PNG, JPG or GIF (max. 800x400px)<br /><br />Max 1 image
                      </div>
                    </Dragger>
                  </Item>

Here is handler func:

 const onFileChanged = async image => {
    if (isDenied(image?.type)) {
      return onNotifyDenied()
    }
    await dispatch(uploadAttachment(image.file))
  }

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source