Relative Content

Tag Archive for reactjstic-tac-toe

Tic Tac Toe using React – how to color only winning buttons?

I have a Tic Tac Toe game in React that works fine, it correctly shows the winner. But if for instance, Player X is winning, it’s coloring with green all the X tiles, not just the winning ones.
I want to color with green only the winning tiles.
I know it doesn’t work with DOM manipulation, I tried using a color in state, but it also colors all the tiles.

what is wrong with the following code to solve react tic-tac-toe game tutorial first challenge

I just completed the tic-tac-toe tutorial on the official website, and attempted the first challenge/improvement as an exercise. I tried the following two versions of code and to me the logic seems to be the same but the first piece of code return a an incorrect result, whereas the second piece works perfectly fine. Can sombody help me understand why the first piece of code does not work correctly? what is worng with the first piece of code?