fix(react): preserve updates across preview remounts#1297
Open
pbroom wants to merge 2 commits intocodesandbox:mainfrom
Open
fix(react): preserve updates across preview remounts#1297pbroom wants to merge 2 commits intocodesandbox:mainfrom
pbroom wants to merge 2 commits intocodesandbox:mainfrom
Conversation
Remounting the only preview could leave the provider idle even after a new client was created, which caused later edits and refreshes to stop updating. Restart Sandpack when a new bundler registers from idle and keep the provider status running once a client is recreated. Made-with: Cursor
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
|
@pbroom is attempting to deploy a commit to the CodeSandbox Team on Vercel. A member of the Team first needs to authorize it. |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
pbroom
added a commit
to pbroom/sandunpack
that referenced
this pull request
Mar 29, 2026
- Proposed an upstream fix for the sandpack-react lifecycle issue as `codesandbox/sandpack#1297`, focusing on the client recreation and provider status during remounts. - Clarified the separation of this fix from the hosted-package issue `codesandbox/sandpack#1296` to facilitate independent review. - Updated notes to reflect the successful validation of the color-kit docs app against the vendored Sandpack build, ensuring reliable preview state preservation during refresh flows.
Queue edits until replacement clients finish initializing and discard stale overlapping client loads. This keeps preview remounts from dropping the next update under React StrictMode. Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
YARN_IGNORE_PATH=1 yarn workspace @codesandbox/sandpack-react builduseClientregressions in the validatedv2.20.0Sandpack mirror:TEST_ENV=true node ../node_modules/jest/bin/jest.js src/contexts/utils/useClient.test.ts --runInBand --runTestsByPath --transformIgnorePatterns "node_modules/(?!@codemirror)/" --modulePathIgnorePatterns e2ecolor-kitunder ReactStrictMode: initial load -> edit -> refresh -> edit -> refreshMade with Cursor