Skip to content

Instantly share code, notes, and snippets.

@ernestlv
Last active July 5, 2023 19:48
Show Gist options
  • Save ernestlv/23180160097be349d54293a1947b634a to your computer and use it in GitHub Desktop.
Save ernestlv/23180160097be349d54293a1947b634a to your computer and use it in GitHub Desktop.
#React - Dynamic List using loop
const Square = ( {text} ) => { // Root Functional Component
console.log("render square:", text);
// View
return (
<div style={{display:'table', backgroundColor:'blue'}}>
{
[1,2,3].map((key) => {
return (
<div key={key} style={{display:'table-cell', backgroundColor:'red'}}>
{ text }
</div>
);
})
}
</div>
);
}
const root = ReactDOM.createRoot(document.querySelector("#app"));
root.render(<Square text="Hello!!!"/>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment