Skip to content

Instantly share code, notes, and snippets.

@batbrain9392
Forked from danielgnz/tic-tac-toe-1.jsx
Last active March 11, 2020 23:31
Show Gist options
  • Save batbrain9392/7127005cca83e28effc1ffe18db7fd1d to your computer and use it in GitHub Desktop.
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
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