Skip to content

Instantly share code, notes, and snippets.

@coleenhuang
Created July 30, 2020 02:41
Show Gist options
  • Save coleenhuang/fc5e2b41f8d0147983dc7115352887d5 to your computer and use it in GitHub Desktop.
Save coleenhuang/fc5e2b41f8d0147983dc7115352887d5 to your computer and use it in GitHub Desktop.
How to render a component x times with Jsx
//making a loop and putting return statements in it doesn't work
//Need to put the components into an array first before rendering
//This is the right way to do it
let cardList = [];
for (let i=0; i < num; i++) {
cardList.push(<Card key={i} />)
}
return <div>{cardList}</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment