fix: resolve Page Builder hydration mismatch in SliceSimulator#131
Open
angeloashmore wants to merge 3 commits into
Open
fix: resolve Page Builder hydration mismatch in SliceSimulator#131angeloashmore wants to merge 3 commits into
angeloashmore wants to merge 3 commits into
Conversation
Always render the root div in the slice simulator iframe, removing the render-time window check that caused a server/client mismatch. The simulator manager now initializes once rather than re-running on router identity changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
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.
Resolves: prismicio/slice-machine#1768
Description
The App Router version of
<SliceSimulator>has atypeof window === undefinedcheck to conditionally read the simulator URL'sstateparam; if rendered on the server, we don't read the parameter. The check is part of the component's render cycle, not in auseEffect.This kind of check can lead to a React hydration error where the server renders as if there is no
stateparam and the client renders using the actualstateparam value. The mismatch can throw an error.This PR simplifies
<SliceSimulator>to ignorewindowaltogether. The change simplifies<SliceSimulatorand the underlying code and eliminates a possible bug.Checklist
Preview
How to QA 1
Note
Low Risk
Client-only behavior is simplified and event subscriptions are stabilized; main risk is subtle changes in simulator rendering when no slices/message are present.
Overview
Removes URL
stateparsing from the App RouterSliceSimulatorrender path (droppinggetSlices/hasSlices) to prevent server/client hydration mismatches.Stabilizes the
StateEventType.Sliceshandler by using arouterRefand an empty-effect dependency array, and simplifiesSliceSimulatorWrapperto always render the simulator root when no message is present (no longer conditionally hides content based onhasSlices).Written by Cursor Bugbot for commit d7ef5ae. This will update automatically on new commits. Configure here.
Footnotes
Please use these labels when submitting a review:
⚠️ #issue: Strongly suggest a change.
❓ #ask: Ask a question.
💡 #idea: Suggest an idea.
🎉 #nice: Share a compliment. ↩