I'm familair with mapping through and array to render something for each number in an array. But what is an effective way to accomplish the same thing using a number.
I've found myself in a situation where I have an integer
representing number of pages and a component <Page>
which takes the prop pageNumber
.
I've got the following render function in place:
renderPages() {
for (let i = 1; i < this.state.numPages; i++) {
return <Page pageNumber={1} />;
}
}
The renderPages
function is implemented as follows in my class render
function:
render() {
return (
<div>
{this.renderPages()}
</div>
);
}
I understand that once the first return occures the renderPages
is exited. So in the end it only renders the first page. How can I render more pages here?