[Suggestion]: Improve code in Tic-Tac-Toe demo
Open
Nobody has claimed this yet.
type: documentation
- Dominant language
- JavaScript
- Stars
- 11.8k
- Forks
- 7.9k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 11
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open the Tic-Tac-Toe tutorial at https://react.dev/learn/tutorial-tic-tac-toe and review the Board, Square, and styling examples. Update the demo to generate squares with map and demonstrate key, use a three-column grid, and delegate clicks to the parent container; the tutorial should remain understandable and functional.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- documentation, frontend
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100