Fix React19Dispatcher html/body attribute handling to be instance-aware#263
Merged
Fix React19Dispatcher html/body attribute handling to be instance-aware#263
Conversation
Co-authored-by: staylor <52932+staylor@users.noreply.github.com>
Co-authored-by: staylor <52932+staylor@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update to address feedback on v3.0.0 — React 19 support and TypeScript cleanup
Fix React19Dispatcher html/body attribute handling to be instance-aware
Mar 3, 2026
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.
React19Dispatchermanaged html/body attributes globally:componentWillUnmountblindly cleared all managed attributes regardless of other mounted instances, so unmounting an inner<Helmet>would wipe attributes that an outer<Helmet>still owns.Changes
Instance registry + merged sync (
src/React19Dispatcher.tsx)react19Instancesarray tracking all mountedReact19DispatcherinstancessyncAllAttributes()— merges html/body attributes across all registered instances (later-mounted wins on conflicts, matching legacyreducePropsToStatesemantics), then applies the merged result to the DOMcomponentDidMountregisters the instance and callssyncAllAttributes()componentWillUnmountunregisters first, then callssyncAllAttributes()— remaining instances' attributes are preservedrender()(init() → applyNonHostedAttributes()); deleted both now-dead methodsMulti-instance tests
htmlAttributes.test.tsx: inner instance overrides outer on conflicts; unmount of inner restores outer's attrs; non-conflicting attrs from two instances are mergedbodyAttributes.test.tsx: same override and restore scenarios for body attributesExample of the fixed behavior:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.