[Bug]: "Clear" / "Reload" button in CodeSandbox does not reset user edits to original sample code
Nobody has claimed this yet.
- 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:
- Navigate to the "Treat state as read-only" section in the React documentation.
- 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
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
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