I´m trying to dinamically create some elements based on a list of JSON objects like this:
{Object.entries(this.state.topTen).forEach(([name]) => {
console.log(name); // this correctly print the list of names
React.createElement(MyCustomComponent, {name: name});
})}
I also tried the following approach inside the loop:
<MyCustomComponentname={name} />
But I don´t see anything rendered in the screen, I know for sure that this.state.topTen
has the correct information because the console.log
inside the loop is displaying the correct information. And if I add a <MyCustomComponentname={name} />
outside of the loop, the component is rendered correctly.