Skip to content
Advertisement

how can you set a dynamic list in react?

I have a list like this

JavaScript

My problem is, I want to set the maximum days of the list from a configuration so sort of like this

JavaScript

I know this seems an easy thing to implement but Im new to react and cannot seem to find a similar question. Thanks

Advertisement

Answer

A common way is to use Array.prototype.push to populate such an array:

JavaScript

Or you could use array APIs such as Array.from to dynamically generate such an array directly.

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