Code Monkey home page Code Monkey logo

Comments (9)

hungdev avatar hungdev commented on July 28, 2024 3

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.

RWTloopesko avatar RWTloopesko commented on July 28, 2024 1

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.

niladri407 avatar niladri407 commented on July 28, 2024

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.

csmartinsfct avatar csmartinsfct commented on July 28, 2024

To fix it you can also use a new key in the component every time you load a new file.

from react-csv-reader.

nzambello avatar nzambello commented on July 28, 2024

I see that it's happening on Chrome and Safari and not on Firefox.
I'm looking at the difference

from react-csv-reader.

danielperaza avatar danielperaza commented on July 28, 2024

I have the same issue

from react-csv-reader.

cvanputt avatar cvanputt commented on July 28, 2024

Has there been any resolution to this issue?

from react-csv-reader.

adebayoileri avatar adebayoileri commented on July 28, 2024

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.

GisliBG avatar GisliBG commented on July 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.