-
-
Save batbrain9392/7127005cca83e28effc1ffe18db7fd1d to your computer and use it in GitHub Desktop.
React tic-tac-toe tutorial - Rewrite Board to use two loops to make the squares instead of hardcoding them
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
render() { | |
return ( | |
<div> | |
<div className="board-row"> | |
{ | |
Array(3).fill(null).map((_, i) => { | |
const row = Array(3).fill(null).map((_, j) => this.renderSquare(3 * i + j)); | |
return ( | |
<div key={i} className="board-row"> | |
{row} | |
</div> | |
); | |
}) | |
} | |
</div> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment