Bunlong / react-papaparse

react-papaparse is the fastest in-browser CSV (or delimited text) parser for React. It is full of useful features such as CSVReader, CSVDownloader, readString, jsonToCSV, readRemoteFile, ... etc.
https://react-papaparse.js.org
MIT License
370 stars 61 forks source link

Prevent config prop mutation #72

Closed Dalitzky closed 3 years ago

Dalitzky commented 3 years ago

I've noticed that once I pass config object to react-papaparse (worker or encoding for exmaple) then data is mutated. For example:

  1. Provide config object with encoding
  2. Load first file & inspect "onDrop" returned data.
  3. Remove first file.
  4. Load second (different) file & inspect "onDrop" returned data. You will see that this time, data is been aggregated with previous file data.

Please find the attach CodeSanBox

Disclaimer: I prefer the object spread rather then object assign but for the sake of similarity I kept it the same.