I have this Upload component that I got from antd : react ant design documentation
<Upload
beforeUpload={()=> {
return false; }}
onChange={e => onChangeFile(e, index)}
onRemove={e => onRemoveFile(e, index)}
>
<Button
icon={<UploadOutlined />}
>
Upload a file
</Button>
</Upload>
After uploading the file, a remove icon appears. When I click on the remove button the file does not get removed from the state.
here is the onChange function :
const onChangeFile = (info, index) => {
console.log(info);
const newForm = form;
newForm.inputs[index].value = info.file;
setForm({
...form,
from: newForm
});
console.log(from);
};
I tried removing using onRemove function like this:
const onRemoveFile = (info, index) => {
const newForm = form;
newForm.inputs[index].value = null;
setForm({
...form,
from: newForm
});
console.log(form);
};
screenshot of the UI: