Skip to content

Conversation

@SaifUrRehman2k
Copy link

[Docs]: Add mutation is unreliable and should be avoided

Closes #8147

  • This PR updates the documentation to provide a more accurate and technically correct explanation of why state mutation should be avoided in React.
  • The previous documentation often used phrases like "not recommended" or suggested mutation was a bad practice. This was misleading for beginners.

Problem:

Multiple sections in the React documentation misleadingly describe state mutation as "not recommended" or something you can "get away with," when the fundamental issue is that mutating state doesn't trigger re renders.

Key Changes:

The language is updated across relevant pages to emphasize the core technical reason for immutability:

  • Mutation does not trigger a re-render.
  • Replaced vague warnings with strong language like "unreliable," "should be avoided," and "fundamentally prevents re-renders."
  • Stresses that immutability is required for state updates to work correctly, not just a preference or best practice.

📄 Files Affected:

  • src/content/learn/tutorial-tic-tac-toe.md
  • src/content/learn/updating-arrays-in-state.md
  • src/content/learn/updating-objects-in-state.md

@meta-cla
Copy link

meta-cla bot commented Nov 29, 2025

Hi @SaifUrRehman2k!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@github-actions
Copy link

Size changes

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

Five Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/404 127.9 KB (-1 B) 238.44 KB
/500 127.91 KB (-1 B) 238.45 KB
/[[...markdownPath]] 130.34 KB (-1 B) 240.88 KB
/errors 128.15 KB (-1 B) 238.69 KB
/errors/[errorCode] 128.13 KB (-1 B) 238.67 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

@meta-cla
Copy link

meta-cla bot commented Nov 29, 2025

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla bot added the CLA Signed label Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant