I tired to show five blocks in the ui view. on click of next button next five data should display and hide first 5 data block like that click on next button ,display next set of 5. my code here using javscript/react
.parent{
display: flex;
}
.child{
margin: 2% 0 0 0;
width: 33%;
}
<div className="parent" >
{list &&
list.data.map((item, index) => (
<div key={index} className="child">
{item.name}
</div>
))}
</div>
2
Answers
For a simple pagination you can use Array.slice()
And add useState to change the pageNum with the button clicks.
Create clickHandlers for the buttons to increment/decrement pageNum.
If you are trying to page data in React,
if you know the current page index, page size and your data length; you can calculate the index offsets like so: