-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onFileLoaded doesnt return data for second time #45
Comments
I found a way to fix it, use if else to check in onFileLoaded func, and clearing data:
and attach id to component: inputId='CSVReader' like this:
But I think its bad way. I hope we can use better solution. Because i think we shouldnt use pure js ( document.getElementById ) in ReactJs. |
Same issue is with me. It's working properly in firefox but in chrome and edge It's not reading the file from second time. |
I'm having the same issue in Chrome. hungdev's solution works well but it seems like there should be a more "Reactish" way to do this. There should be a method to clear the input after it loads. |
To fix it you can also use a new |
I see that it's happening on Chrome and Safari and not on Firefox. |
I have the same issue |
Has there been any resolution to this issue? |
Seems the issue still persists, a "react" way could be the import { useRef } from 'react';
const csvRef = useRef(); <CSVReader
inputId='CSVReader'
inputStyle={{ display: 'none' }}
onFileLoaded={(data) => {
handleForce(data);
csvRef.current.value = '';
}}
parserOptions={papaParseOptions}
inputRef={csvRef}
/> |
If you are looking for a work around, what @csmartinsfct works. Add a key prop to the component and make sure to create a new key after each time onFileLoaded executes. |
Describe the bug and Reproduce
If the file loads the first time, the file has a duplicate header, it calls the onFileLoaded function, but the second load is the same file, it will not call the onFileLoaded function anymore.
Expected behavior
2nd time it still has to run into function onFileLoaded
Screenshots
If applicable, add screenshots to help explain your problem.
Platform (please complete the following information):
CSV file: https://drive.google.com/file/d/1QfDRRAzsHZ6P4IiXNq-pUNba2KkOQd3u/view?usp=sharing
My code:
The text was updated successfully, but these errors were encountered: