react.dev
react.dev copied to clipboard
Tutorial Code Allows Overwrite of Squares
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.
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?
Thanks for catching this!
The new version of the tutorial covers this here: https://react.dev/learn/tutorial-tic-tac-toe#taking-turns
Closing, since we're no longer updating the legacy docs.