Skip to content
Advertisement

How to loop React Elements for a specific amount of times?

I am trying to make a looper component so that I can loop any of its children for a specific amount of time. How can I do that?

JavaScript

Advertisement

Answer

You can create an array of incrementing numbers on the fly using [...Array(times).keys()], like so:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement