Skip to content

Conversation

@RuthieRNewman
Copy link

No description provided.

…ick function to Square component, adds function to mark board with appropriate symbol in response to click.
Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you know you haven't gotten to detecting the winner yet, but you're pretty close. I left some notes to take a look at. Let me know if you have questions.

// empty value and unique ids.
const [squares, setSquares] = useState(generateSquares());
const [currentPlayer, setPlayerState] = useState(PLAYER_1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also suggest you might want a state variable to keep track of the winner.

})
}

const checkForWinner = () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting this function is still essentially blank.

I suggest making a loop that goes through the rows checking to see if:

squares[i][0].value === squares[i][1].value and squares[i][0].value === squares[i][2].value

Then do something similar for the columns. The diagonals you have to do manually.

})
});

const squareComponents = flatList.map(data => <Square id={data.id} value={data.value} onClickCallback={onClickCallback} ></Square>)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants