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

[Suggestion]: Improve code in Tic-Tac-Toe demo

Open prajwalkulkarni opened this issue 1 year ago • 3 comments

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 Board component returns the Square component statically. This could instead be returned dynamically using the map method. This will also be a good way to demonstrate the key prop.
  • Talking about the styling, instead of defining a board-row class that puts each box in a row, we can instead use a grid container with 3 columns and fit-content width.
  • Instead of attaching a click listener to each box, the click event handling can be delegated to the parent container.

prajwalkulkarni avatar Jul 07 '24 13:07 prajwalkulkarni

It's a good suggestion! may I open a pull request?

prittoruban avatar Jul 08 '24 17:07 prittoruban

Sure

prajwalkulkarni avatar Jul 08 '24 17:07 prajwalkulkarni

I've edited it according to your suggestion, is it ok?

prittoruban avatar Jul 08 '24 17:07 prittoruban