SarahFrench / react-game-of-life

Re-creating my Conway's Game of Life project in React
https://sarahfrench.github.io/react-game-of-life/
0 stars 0 forks source link

Cell doesn't need x and y props to be passed to it. #5

Closed TomAFrench closed 4 years ago

TomAFrench commented 4 years ago

https://github.com/SarahFrench/react-game-of-life/blob/3c0a88fd92d0691124fcc75e10600f3c019f3cb6/src/components/Board.js#L17

You can bake the location of the cell into the toggleCellState prop to prevent the cell from needing to know where it is on the board.

<Cell key={`cell-${yRowNumber}-${xColumnNumber}`} status={cell} toggleCellState={() => this.props.toggleCellState(xColumnNumber, yRowNumber)} />

You'll need to adjust the Cell component to match.

SarahFrench commented 4 years ago

Ah yeah! Thanks for this