reactjs / reactjs/react.dev

[Suggestion]: Tic-tac-toe tutorial should explicitly explain that mutation causes unreliable re-rendering

Open
#8,086 1 comment 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

The tutorial's Why immutability is important section doesn't clearly state that mutating state causes unreliable re-rendering behavior.

Page

https://react.dev/learn/tutorial-tic-tac-toe#why-immutability-is-important

Details

While following the tic-tac-toe tutorial, I was confused about why .slice() is necessary. The "Why immutability is important" section talks about time travel features and performance optimizations, but it never explains that mutating the array directly will cause React to not reliably detect the change, meaning the component may not re-render.

It seems as though that is the primary reason the tutorial uses .slice(), but it's not mentioned. I only found this explanation later in the "Updating Objects in State" article. It would be helpful to include this explanation in the tutorial where beginners first encounter the pattern.

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 linked Tic-tac-toe tutorial at the “Why immutability is important” section and compare it with the referenced “Updating Objects in State” article. Update the tutorial to explain that direct mutation can prevent React from reliably detecting changes and re-rendering, then verify that the explanation fits the existing discussion of slice(), time travel, and performance.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.