react-papaparse icon indicating copy to clipboard operation
react-papaparse copied to clipboard

Cannot find a way to remove a file programatically

Open des09 opened this issue 5 years ago • 13 comments

My specific use case is after a successful parse, I want to show an upload form, with a preview of the parsed data. So far so good, but if the upload succeeds, or if the user elects to cancel the form, I want to return to the state things were in before a file was dropped.

I have found your component to be very easy to use so far. Thanks.

des09 avatar Aug 14 '20 19:08 des09

@des09 Thank you for your contribution. I will add it in the next release next week. Could I add you in the contributor list? Thanks!

Bunlong avatar Aug 17 '20 15:08 Bunlong

Yes, you may add me as a contributor. Should I look for the remove feature in 3.7.4?

des09 avatar Aug 27 '20 14:08 des09

@des09 You are added to contributor list. Okay we will add remove feature in next version 3.8.0. Thanks you!

Bunlong avatar Aug 30 '20 06:08 Bunlong

I am also looking for this functionality, I need a way to clear the file when some exterior condition changes. Maybe some kind of hook? Really looking forward to this. Thanks and keep up the good work @Bunlong.

mysticaltech avatar Sep 03 '20 09:09 mysticaltech

@mysticaltech I'v done it in v3.8.0. I will release it by tomorrow or this week. Thank you so much!

Bunlong avatar Sep 03 '20 17:09 Bunlong

@Bunlong , It will be greate if you can release this featue as fast as possible. I am waiting for the same.

avestaHarsh avatar Sep 04 '20 04:09 avestaHarsh

@Bunlong Thank you, looking forward to it. I love where this project is going! 🙏🏻

mysticaltech avatar Sep 04 '20 06:09 mysticaltech

@des09 @mysticaltech @avestaHarsh react-papaparse v3.8.0 has been released with the following features:

  • CSVDownloader
  • isReset? – Is used to reset CSVReader or remove file in CSVReader

How to reset CSVReader? – Please look for isReset props in the docs.

Thank you so much!

Bunlong avatar Sep 05 '20 18:09 Bunlong

Thank you so much @Bunlong! However I am not able to use it. I have tried to set it up to a boolean value of "true" all the time but everything stays the same as before.

It would make more sense to me if it was a function or hook that we could call to reset the component on demand. Maybe a short example would help me understand better how to use it 🙏🏻

mysticaltech avatar Sep 07 '20 16:09 mysticaltech

@mysticaltech

I'm sorry for late reply as I was so busy in few day ago.

Please kindly check Sample of using CSVReader isSet.

I will rewrite exiting based component to hooks in version 4.0.0.

If you have any question feel free to ask me. Thanks :pray:

Bunlong avatar Sep 09 '20 01:09 Bunlong

No problem at all. I thought of doing doing it using state, but instead just set it to "true". But nothing happened but what happened. I guess the problem is that it always stays at the same value of true.

Thank you for your button toggle example above, in that case I would guess that we would need to click twice to make it work, initial state is false, then we click to make it true and reset, then we click another time to make it false again and let the drop area work normally. Correct?

In my case I can't use it this way, as I need to reset when an outside state parameter changes. So a function that would basically "clear the cache, and the loaded file in that matter" would be ideal.

I will wait patiently for 4.0.0 🙏🏻 ✨

mysticaltech avatar Sep 09 '20 05:09 mysticaltech

it's still not entirely obvious how this would be done. can anyone make an example with a buttonref implementation?

Weilin37 avatar Dec 31 '21 23:12 Weilin37

how to implement this in the hooks-based component?

chetanraj avatar Mar 01 '23 11:03 chetanraj