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

232
Views
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
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!