Closed TomAFrench closed 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.
toggleCellState
<Cell key={`cell-${yRowNumber}-${xColumnNumber}`} status={cell} toggleCellState={() => this.props.toggleCellState(xColumnNumber, yRowNumber)} />
You'll need to adjust the Cell component to match.
Ah yeah! Thanks for this
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.You'll need to adjust the Cell component to match.