reactjs / reactjs/react.dev

[Bug]: "Clear" / "Reload" button in CodeSandbox does not reset user edits to original sample code

Open
#8,657 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug: unconfirmed
Dominant language
JavaScript
Stars
11.8k
Forks
7.9k
Avg merge
1d 11h
Merged PRs (30d)
11

Description

Summary

Component: Interactive Code Sandbox

Steps to Reproduce:

  1. Navigate to the "Treat state as read-only" section in the React documentation.
  2. Modify the sample code inside the sandbox. Change:

position.x = e.clientX;
position.y = e.clientY;

to:

const p = { x: e.clientX, y: e.clientY };
setPosition(p);

3.Observe that the red dot starts following the cursor as expected.
4.Click the "Clear" or "Reload" button on the sandbox to undo the edits and restore the original code sample.

Expected Result:
The sandbox should revert to the original, unedited sample code (position.x = e.clientX), and the red dot should stop following the cursor.

Actual Result:
The red dot continues to follow the cursor despite triggering a reset.

Page

https://react.dev/learn/updating-objects-in-state

Details
Image

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

Start by reproducing the reset behavior on the "Treat state as read-only" section of react.dev/learn/updating-objects-in-state, then trace the Interactive Code Sandbox reset flow. Done means Clear or Reload restores the original sample code and the red dot no longer follows the cursor.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.