Last active
July 5, 2023 19:48
-
-
Save ernestlv/23180160097be349d54293a1947b634a to your computer and use it in GitHub Desktop.
#React - Dynamic List using loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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