Skip to content
Advertisement

React – problem in rendering array of components

JavaScript
JavaScript

i wanted to insert 9 components in Lottery components.but nothing shows up. can someone just explain to me why a relationship like this doesn’t work in React? and what is the wrong practice used here?

Advertisement

Answer

  1. Init i in the for loop with a 0i = 0
  2. push the circles into the row – circlesrow.push(<Circle />)
  3. Call the function – {circles()}

JavaScript
JavaScript

You can also generate the circles’ array with Array.from() direcly:

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