react-papaparse
react-papaparse copied to clipboard
Cannot find a way to remove a file programatically
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 Thank you for your contribution. I will add it in the next release next week. Could I add you in the contributor list? Thanks!
Yes, you may add me as a contributor. Should I look for the remove feature in 3.7.4?
@des09 You are added to contributor list. Okay we will add remove feature in next version 3.8.0. Thanks you!
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 I'v done it in v3.8.0. I will release it by tomorrow or this week. Thank you so much!
@Bunlong , It will be greate if you can release this featue as fast as possible. I am waiting for the same.
@Bunlong Thank you, looking forward to it. I love where this project is going! 🙏🏻
@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!
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
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:
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 🙏🏻 ✨
it's still not entirely obvious how this would be done. can anyone make an example with a buttonref implementation?
how to implement this in the hooks-based component?