Comments (9)
I found a way to fix it, use if else to check in onFileLoaded func, and clearing data:
(document.getElementById('CSVReader') as HTMLInputElement).value = '';
and attach id to component: inputId='CSVReader' like this:
<CSVReader
inputId='CSVReader'
inputStyle={{ display: 'none' }}
onFileLoaded={handleForce}
parserOptions={papaParseOptions}
/>
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.
from react-csv-reader.
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.
from react-csv-reader.
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.
from react-csv-reader.
To fix it you can also use a new key
in the component every time you load a new file.
from react-csv-reader.
I see that it's happening on Chrome and Safari and not on Firefox.
I'm looking at the difference
from react-csv-reader.
I have the same issue
from react-csv-reader.
Has there been any resolution to this issue?
from react-csv-reader.
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.
Seems the issue still persists, a "react" way could be the useRef
import { useRef } from 'react';
const csvRef = useRef();
<CSVReader
inputId='CSVReader'
inputStyle={{ display: 'none' }}
onFileLoaded={(data) => {
handleForce(data);
csvRef.current.value = '';
}}
parserOptions={papaParseOptions}
inputRef={csvRef}
/>
from react-csv-reader.
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.
from react-csv-reader.
Related Issues (20)
- No support of React-csv-reader for React version 18
- title/balloon help override HOT 2
- Can't open files list from chrome
- validating csv file HOT 9
- npm run build failed to compile in create-react-app project HOT 3
- Camel case naming convention HOT 2
- How to customize the CSVReader file upload into button HOT 1
- How can I access default file info using e.target.files[0] for uploading loaded file to server using axios? HOT 2
- is it possible to run onFileLoaded when I am manually adding the file using drop event
- add `inputRef` feature HOT 2
- Support for xlsx input HOT 1
- upgrade peer dependency React to v17.0.2 HOT 1
- custom delimeter for csv HOT 1
- npm run build failed to compile HOT 1
- Translation? HOT 1
- project is dead? HOT 1
- Hosted Link is not working HOT 1
- onFileLoaded function error HOT 1
- React peer dependency version doesn't resolve for React 17 projects anymore HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-csv-reader.