So I'm learning react and js, and I'm trying to loop every 20 (the limit in a single page) and show this pictures, also show in the bottom this pages index using bootstrap. but it not really working this is my code:
const pictureItems = this.state.imgFiles.map((img, index) => {
return (
<PictureListItem
id={index}
key={`img-${img.name}`}
imgFile={img}
pictureDataUpdate={this.onUpdatePicture}
/>
);
});
const pageNumber = this.state.imgFiles.length / 20;
let pages = "";
for (let i = 0; i < pageNumber; i++) {
pages += <li><a>{i}</a></li>;
return pages;
}
I was thinking may be I can pass the value of the index to the loop and multiply by 20 for the start and then add 20 to the end. but I can't even get the pages to show well.