Feature request: onRemovedFile (or something similar)
See original GitHub issueI can’t find a way to know when a file has been removed after it has been uploaded. Here is my code below (very similar to your example). For the remove file button, I tried adding an onClick so that I could capture when the user removed the file - but this just overwrites the getRemoveFileProps. So wondering if there is currently a way to know if a file has been removed and if not maybe it could work in a similar way to “onUploadAccepted”, but obviously gets called when the file is removed.
const { CSVReader } = useCSVReader();
<CSVReader
onUploadAccepted={(results: any) => {
console.log('---------------------------');
console.log(results);
console.log('---------------------------');
setCsvData(results.data)
setZoneHover(false);
}}
onDragOver={(event: DragEvent) => {
event.preventDefault();
setZoneHover(true);
}}
onDragLeave={(event: DragEvent) => {
event.preventDefault();
setZoneHover(false);
}}
>
{({
getRootProps,
acceptedFile,
ProgressBar,
getRemoveFileProps,
Remove,
}: any) => (
<>
<div
{...getRootProps()}
style={Object.assign(
{},
styles.zone,
zoneHover && styles.zoneHover
)}
>
{acceptedFile ? (
<>
<div style={styles.file}>
<div style={styles.info}>
<span style={styles.size}>
{formatFileSize(acceptedFile.size)}
</span>
<span style={styles.name}>{acceptedFile.name}</span>
</div>
<div style={styles.progressBar}>
<ProgressBar />
</div>
<button
{...getRemoveFileProps()}
style={styles.remove}
onMouseOver={(event: Event) => {
event.preventDefault();
setRemoveHoverColor(REMOVE_HOVER_COLOR_LIGHT);
}}
onMouseOut={(event: Event) => {
event.preventDefault();
setRemoveHoverColor(DEFAULT_REMOVE_HOVER_COLOR);
}}
>
<Remove color={removeHoverColor} />
</button>
</div>
</>
) : (
'Drop CSV file here or click to upload'
)}
</div>
</>
)}
</CSVReader>
Version 4.0.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:5
Top Results From Across the Web
[FEATURE REQUEST] Provide `file.absent` with `removedirs` option ...
When that file is no longer needed, file.absent can remove that file, but all directories are kept. ... I'd like to have a...
Read more >[Feature request] Remove file from version control
Hi, With this post I would like to submit a feature request. It would very usefull if a user could select one or...
Read more >Where do I go submit a feature request for OneDrive?
To mitigate the risk of mass file deletion on the Cloud by deleting files from our synced folder, I'd like to request a...
Read more >Feature Request - Individual File 'Revert Local Changes' Review
Should the local copy of this item be deleted? · Should the local copy of this item be accepted into the cluster? ·...
Read more >107006 - Feature request: ability to replay a previously made ...
Like : - I replay POST requests - I care about POST parameters - I do (don't) care about HTML headers. That way...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In @rishipisipati 's code, replacing
getRemoveFileProps.onClick(event);
withgetRemoveFileProps().onClick(event);
worked for me. Otherwise it gives an error.@Angelfire @DanKellyRedcat @jadenmazzone Not sure if you still need assistance, but this is what worked for me to preserve both the onClick method from removeFileProps and calling in my own code.