react.dev
react.dev copied to clipboard
[Suggestion]: Improve code in Tic-Tac-Toe demo
Summary
I believe there's a good scope to improve the code in the Tic-Tac-Toe example here.
Page
https://react.dev/learn/tutorial-tic-tac-toe
Details
- The
Boardcomponent returns theSquarecomponent statically. This could instead be returned dynamically using themapmethod. This will also be a good way to demonstrate thekeyprop. - Talking about the styling, instead of defining a
board-rowclass that puts each box in a row, we can instead use a grid container with 3 columns andfit-contentwidth. - Instead of attaching a click listener to each box, the click event handling can be delegated to the parent container.
It's a good suggestion! may I open a pull request?
Sure
I've edited it according to your suggestion, is it ok?