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

234
Visualizações
React Data Table Lazy Loading or Pagination Loading

I am using react-data-table-component the data will be fetched from a API (which has 10k+ records).

async function getAllData() {
  let nextUrl = "/url/";
  let temp = [];
  let config = {
    headers: {
        Authorization: `token`,
    },
  };
  while (nextUrl !== null) {
    const response = await apiInstance.get(nextUrl, config);
    nextUrl = response.data.next;
    temp.push(...response.data.results);
  }
  return temp;
}

async function tempFunc() {
  let temp1 = await getAllData();
  setDataFromAPI(temp1); // useState
}

tempFunc();

// DataTable

<DataTable
    pagination
    columns={columns}
    data={dataFromAPI}
    customStyles={customStyles}
/>

Right now this function works fine, the problem is the api has 10k+ records, the page is loading until it finishes the while loop.

Instead of this, i wanted to load only the first 30 or 50 then onnext pagination i would like to load the next response.

How can this be done ?

about 4 years ago · Juan Pablo Isaza
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