Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

314
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda