Issues with Tic-tac-toe (reactjs.org Tutorial)

Can someone with React experience help me debug this game?

I just finished working through this tutorial from reactjs.org.

My finished game knows when a player has won, because it no longer allows additional moves. (Try it! You’ll see.)

But, it is not displaying the “Winner: X” status message instead of “Next player” when a player wins. (You can see how it should look in the demo code that goes with the tutorial.)

I have compared my code with the demo line by line, twice!! Found one small bug, but have not been able to find a discrepancy that would explain why my Winner message is not rendering.

Any clues in the right direction would be much appreciated! :slight_smile:

Hi @thehinkydonut,

Line number 85 is preventing the display of the winner

const winner = calculateWinner[current.squares];

It should be const winner = calculateWinner(current.squares); since calculateWinner is a function call that returns the boolean value based on which if(winner) loop gets executed

That makes total sense… Line 60 where it also evaluates calculateWinner(squares) was a separate function call, so that’s why it was working correctly there. Thank you so much!!

1 Like