reactjs / reactjs/react.dev

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

Open
#7,040 3 comments 0 reactions 0 assignees View on GitHub

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 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.