react.dev icon indicating copy to clipboard operation
react.dev copied to clipboard

Tutorial Code Allows Overwrite of Squares

Open jamesobrooks opened this issue 2 years ago • 1 comments

Tic-Tac-Toe Rule Violation

The code in the tutorial allows for overwriting played squares.

Solution

Once the handleClick function has retrieved squares from state, immediately return if the particular square is already truthy.

jamesobrooks avatar Aug 20 '22 16:08 jamesobrooks

I have a fix in my fork, but cannot create the PR to main. Is there a different branch I should branch from to start?

jamesobrooks avatar Aug 20 '22 17:08 jamesobrooks

Thanks for catching this!

The new version of the tutorial covers this here: https://react.dev/learn/tutorial-tic-tac-toe#taking-turns

Screenshot 2024-01-10 at 3 41 38 PM

Closing, since we're no longer updating the legacy docs.

rickhanlonii avatar Jan 10 '24 20:01 rickhanlonii