Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

312
Views
CSV Link from react-csv exporting incomplete data

I'm using CSV Link from react-csv to export CSV data in a table with selectable rows. There is a problem in the way the data is getting exported. When I select 3 rows, for example, it's omitting the last row from the resulting CSV file that is outputted. If I select 4 rows, it will only export 3 rows the first time, and so on. If I hit the export button a second time, the complete set of rows will get exported.

Here is how I'm passing data to the CSV Link component:

<CSVLink
 data={getExportTransactionRows(t.transactions)}
 headers={getExportTransactionHeaders(t)}
 filename={t.companyName}
>

Here is the getExportTransactionRows function that returns the rows:

  const getExportTransactionRows = (transactions) => {
    let trans = transactions.filter((t) => t.selected === true);
    if (trans?.length === 0) trans = transactions;
    return trans;
  };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think the reason why you just keep exporting the previous row is that your getExportTransactionRows(t.transactions)s don't change value right away when you selected row. You can declare a variable that saves your export data. Then in your select event and change that variable when you selected. Passing it into CSVLink

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!