Hope you help me with this, I'm using the useDropzone hook from react-dropzone and I don't know how to make a remove file button for each file.
How can I remove a single file?
This is my code:
function DragFile(props) {
const { acceptedFiles, rejectedFiles, getRootProps, getInputProps } = useDropzone({
accept: 'image/jpeg, image/png, .pdf',
maxSize: 3000000,
multiple: true
});
const acceptedFilesItems = acceptedFiles.map(file => (
<Col xs={12} md={4} key={file.path} className="card-file">
<div className="file-extension">{file.path.substring(file.path.indexOf('.') + 1)}</div>
<span>{file.path.substring(0, file.path.indexOf('.'))} <small>{(file.size / 1000).toFixed(2)} Kb</small></span>
<button className="delete">DeleteButton</button>
</Col>
));
const rejectedFilesItems = rejectedFiles.map(file => (
<li key={file.path}>
{file.path.substring(0, file.path.indexOf('.'))} - {file.size / 1000} Kb
</li>
));
return (
<div>
<div {...getRootProps({ className: 'dropzone drag-n-drop' })}>
<input id="file-claim" {...getInputProps()} />
<img src={uploadSrc} alt="Subir archivo" />
<p>Drag files here (PDF, JPG, PNG).</p>
</div>
<Row className="accepted-files">
{acceptedFilesItems}
</Row>
</div>
);
}
export default DragFile;