I am trying to output a HTML list in JSX.
Here is how I build the array:
let seasonsList = [];
for (var i=0; i < jsonData.data.campaigns.list.length; i++) {
seasonsList.push(<li key={i}>{jsonData.data.campaigns.list[i].name}</li>);
}
When I try to output this list I get nothing inside the ul tags
return (
<ul>{seasonsList}</ul>
);
How can I output the list of names inside the ul tags?
2
Answers
instead using for loop you should try this appraoch
you can try with the below code and also make sure that the index which you are passing as a key prop to the
if still the problem exist then try with passing some unique values which is coming from the data you get in the key prop in