Answer the question
In order to leave comments, you need to log in
How to draw a component in a loop?
Hello everyone, you need to draw a specific number of times the component for this wrote the following function:
const renderPageNumber = (number) => {
for (let i = 1; i <= number; i++) {
<NextIcon i={i} />
}
}
Answer the question
In order to leave comments, you need to log in
If you really need it, you can do something like this:
const renderPageNumber = (number) => {
const nextIcons = Array(number)
.map((icon, id) => <NextIcon i={id + 1} key={?} />);
return nextIcons;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question