Skip to content

Instantly share code, notes, and snippets.

@ammarnajjar
Created November 24, 2019 19:21
Show Gist options
  • Save ammarnajjar/a607a290ddf165d8ab49bac2a902caec to your computer and use it in GitHub Desktop.
Save ammarnajjar/a607a290ddf165d8ab49bac2a902caec to your computer and use it in GitHub Desktop.
use Array.map instead of crap
render() {
return (
<div>
<div className="board-row">
{this.renderSquare(0)}
{this.renderSquare(1)}
{this.renderSquare(2)}
</div>
<div className="board-row">
{this.renderSquare(3)}
{this.renderSquare(4)}
{this.renderSquare(5)}
</div>
<div className="board-row">
{this.renderSquare(6)}
{this.renderSquare(7)}
{this.renderSquare(8)}
</div>
</div>
);
}
render() {
return (
<div>
{[0, 3, 6].map(j => (
<div key={j} className="board-row">
{[j, j + 1, j + 2].map(
i => this.renderSquare(i)
)}
</div>
))}
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment