Skip to content

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

Open

Description

@Fr00tL00ps515

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

Activity

  1. Madhu-priya123 commented on Nov 26, 2026

    @Madhu-priya123

    Hi,

    I would like to contribute to this issue. I'm interested in investigating the CodeSandbox reset behaviour and fixing it so that clicking Clear or Reload restores the original sample code.

    Could you please confirm whether this issue is available for external contributions? I'd be happy to work on it.

    Thank you!

  2. Fr00tL00ps515 commented on Nov 26, 2026

    @Fr00tL00ps515
    Author

    Hi @Madhu-priya123, thanks for your interest!

    There's already an open PR for this (#8668). You could review or test it, or look for another issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions