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
364 stars 61 forks source link

readString: An argument for 'config' was not provided #104

Closed sunrisep12 closed 11 months ago

sunrisep12 commented 2 years ago

I've been using this library for a while but from today it started throwing an error at readString(). I have this const parsedCsv = readString(csvString); from which, later on, I grab parsedCsv.data and parsedCsv.meta.delimiter for my purposes. But now, I can't do that as I get an error that says An argument for 'config' was not provided.. Is there a way to set this config to null and retrieve this data without readString(str, {worker: true, complete: res => someVar = res.data, someDelimiterVar = res.meta.delimiter}) etc. because on this way I should be dealing with async/await if I'd like to assign the data I need to my values, which I'd like to avoid.

Bunlong commented 2 years ago

@sunrisep12

readString API has been changed in latest version 3.18.0 as following:

readString(csvString, {
  worker: true,
  complete: (results) => {
    console.log(results)
  }
})

Please kindly check the docs on readme or website. Thanks!

flowerbot commented 2 years ago

Getting same error trying to use readRemoteFile, what is the fix/workaround? Sorry very limited React knowledge, don't really understand what the above response means. Config is not being recognised at all, nor can I leave it blank although documentation says its 'optional'.

Edited Today (24/11) I rolled my install back to version 3.17.2 and the problem went away, its a bug.

Bunlong commented 2 years ago

@flowerbot @sunrisep12

radString API has been changed from:

const parsedCsv = readString(csvString, { worker: true });

To

readString(csvString, {
  worker: true,
  complete: (parsedCsv) => {
    console.log(parsedCsv);
  }
});
plotka commented 2 years ago

I was also struggling with this after the update. Looks like the docs are not up to date here https://react-papaparse.js.org/docs#strings. Also, why is worker a required prop if it should be always true, in this case?