I want to know if there is a way to create and render multiple elements dynamically instead of having to manually write each one in React.
Coming from javascript there were options like the following:
let parent document.getElementById("parent");
let html = "";
for (let i = 0; i < 10; i++) {
html += "<div>Div + (i + 1) + "</div>";
}
parent.innerHTML
Or:
let parent = document.getElementById("parent");
for (let i=0; i < 10; i++) {
let div = document.createElement("div");
div.innerHTML = "Div + (i + 1);
parent.appendChild(div);
}
i tried for loops, making functions containing only the code for creating multiple divs, tried placing the function or the for loop in different places in my component or even outside of it. also tried looking up online but I can't seem to find an answer and I keep running into errors