board array contains 4 numbers, one of them will be randomly changed to the number 1, i need to get the value of that number on click. There are 4 buttons for each board numbers.
class GameContainer extends React.Component {
state = {
board: [0, 0, 0, 0]
};
generateBoard = () => {
const newBoard = this.state.board;
const random = Math.floor(Math.random() * 4);
newBoard[random] = 1;
return newBoard;
};
findWinner = () => {
};
componentWillMount = () => {
const board = this.generateBoard();
console.log("BOARD:", board);
this.props.createBoard(board);
console.log("Board created");
};
onClick = event => {
console.log("Click received!", event.target.id);
this.findWinner();
};
randomsomewhere (state)? Hard to say without having a complete example.