react-csv / react-csv

React components to build CSV files on the fly basing on Array/literal object of data

Home Page:http://react-csv.github.io/react-csv/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting empty CSV files after upgrading to React 18

kwalk2108 opened this issue · comments

It was working fine with React v17 but now when exporting, I just see empty files. I reverted back to React 17 and it's working again.

Here's the code:

image

I confirmed the data is getting to the component and there are no errors.

Having the same issue

I resolved this issue by adding some logic and to check if the async data populating the CSV had finished downloading and added to the local state prop. Then I used a setTimeout to click the CSV link and open the file. It's not a pretty solution but seems to be getting the job done

The primary issue is with using createRoot vs ReactDOM.render. Switching between how the app is rendered is what triggers the mis-ordered data -- it is always 1 render behind.

The primary issue is with using createRoot vs ReactDOM.render. Switching between how the app is rendered is what triggers the mis-ordered data -- it is always 1 render behind.

Exactly this happened to my project. I got the warning https://reactjs.org/link/switch-to-createroot after an update, then applied the change and started having this problem.