Data Table
React.js
hard
35 mins
Build a React component that renders a table from given data with pagination and page size selection. Users should be able to:
- View tabular data.
- Navigate between pages.
- Change how many rows are shown per page.
Requirements
- Accept a list of objects as a prop called
data.
data: An array of objects, where each object hasid,name, andage.
-
Table Structure
- Display headers:
"id","name", and"age". - Render data rows based on the current page and selected page size.
- Display headers:
-
Pagination
- Show a "Next" and "Previous" button.
- Initially display 5 rows per page.
- Clicking "Next" should move to the next page of data.
- Clicking "Previous" should go back one page.
- The "Previous" button should be disabled on the first page.
-
Page Size Selector
- The default page size must be 5.
- Provide a dropdown to change page size (e.g., 5, 10, 20).
- Selecting a new size should update the number of rows shown accordingly.
Constraints & Edge Cases
- Changing page size should reset the current page to 1.
- Do not allow navigating beyond available pages.
Reference UI

Preview what you need to build
Companies:
meta
uber
zomato
Solve Similar questions 🔥
Want to upskill? Explore our courses!
Namaste DSA
Master DSA from scratch with numerous problems, and expert guidance.
Namaste React
Wanna dive deep into React and become Frontend Expert? Learn with me now!
Namaste Frontend System Design
The most comprehensive and detailed course for frontend system design.
Namaste Node.js
Wanna dive deep into Node.js? Enroll into `Namaste Node.js` now!
