2.0.1 do not generate csv data
after update 1.1.2 to 2.0.1 saved files are empty. header(first row) is present, but no data. after rollback to 1.1.2 all working fine
thank you for reporting the issue. I am looking into it.
@Krasnopir I tried to reproduce the issue, by running the example website docker-compose up -d .. then, visit http://localhost:8008 .. I exported the CSV file and no issue.
Could you please give more details ? like snippet of data you are exporting.. so on.
Hi! i also tried simple mock case, and it work. But my case, is maybe strange, i need to get async data after button click. and 1.1.2 worked) https://codesandbox.io/s/green-sea-mew7u?fontsize=14&hidenavigation=1&theme=dark
maybe is there some better idea how can i do it. Thank!
i find async examples at doc. And also will try to use CSVDownload from package.
there some troubles to get data from out of async function (ex. axios). I need set it to component state. but useState are sync and there no way add callback, only useEffect, but it is not good solution, because generated data can be the same multiple times, and nothing will not triggered download. and i think it is overhead. The best solution is to use done(data) and not use data={data} for async cases
Also CSVDownload i can not use. After data generation i mount a component. But after file downloading, there no way to trigger download more time. As solution can be add callback after file download window open. (ex. onDownloaded) and this callback can trigger clear data in component state, and next click will generate new data and mount CSVDownload again
I am feeling that if we merge this PR #179, the issue will be fixed. Could you please check with me and confirm ? If so, we will need help from @djently to resolve the PR conflicts
The safest way to get rid of deprecated lifecycle methods is to convert the implementation to functions/hooks.
Would recommend doing as such, and bumping up to v3.
For others who are looking for a solution, you can also use this dependency to achieve the same result using regular Javascript (no react):
https://github.com/silverwind/save-csv
@avindra thanks. i try to use save-csv in my react app
import saveCsv from 'save-csv';
onCompleted: data => {
saveCsv(
mapData(data?.trackFlatFilteredList?.items),
{
filename: `export-${getCurrentDateTime()}.csv`,
sep: ';',
}
);
},
all is ok!
It seems that if I mutate the data in the render at all the csv data is invalid. If I give it static data it generates the csv correctly.
I have the same question in my project, first time I download .csv file, the data is null, the second time csv data updated, but next is the second time data, and I check props data is my current fetch data, it seems like the link is not update
I'm having the same issue, reverted back to previous version for now
Hello guys, if you have a fix for this bug, please open PR. And reach me here http://in.abdennoor.com and i will review it immediately.
@mccabemj we need your help
having the same issue
another option to use export-to-csv package that enable to customize first row - header unlike saveCsv and also work whith async data
import { ExportToCsv } from 'export-to-csv';
onCompleted: data => {
const csvExporter = new ExportToCsv({
fieldSeparator: ';',
showLabels: true,
filename: `export-${getCurrentDateTime()}.csv`,
useKeysAsHeaders: false,
headers: getHeader(),
});
csvExporter.generateCsv(mapData(data?.items));
},
This issue is likely fixed by https://github.com/react-csv/react-csv/pull/211 2.0.1 isn't handling property changes correctly.
Thank you guys, Thank you @mitchell-bu
🎉🎉🎉🎉🎉🎉🎉
It is now merged and the new version is 2.0.2
https://github.com/react-csv/react-csv/releases/tag/v2.0.2
@mitchell-bu for subsequent issues, please reach me on linkedin as I got notified immediately there: http://in.abdennoor.com