Repository navigation
feat(react)!: support universal components in the v0_9 renderer - #2849
Merged
Merged
Conversation
josemontespg
force-pushed
the
react-portal-hosts-node
branch
from
September 28, 2026 18:44
ea92119 to
5401238
Compare
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a breaking change to the React renderer by ensuring every catalog component renders inside its own custom element host, with React implementations portaled into these hosts from a single React root. It adds a HostRegistry to track connected host elements per surface and introduces helper utilities like toWebComponent to dynamically define custom elements. The reviewer's feedback highlights a potential runtime TypeError in toWebComponent if the implementation object or its name is undefined, suggesting defensive checks to ensure robustness.
josemontespg
force-pushed
the
react-portal-hosts-node
branch
from
September 28, 2026 18:58
5401238 to
80621c3
Compare
josemontespg
force-pushed
the
react-portal-hosts-node
branch
from
September 28, 2026 19:40
80621c3 to
cba3d42
Compare
josemontespg
commented
Sep 28, 2026
josemontespg
force-pushed
the
react-portal-hosts-node
branch
2 times, most recently
from
September 28, 2026 20:21
f1a1dd5 to
b7827f0
Compare
josemontespg
commented
Sep 28, 2026
josemontespg
force-pushed
the
react-portal-hosts-node
branch
2 times, most recently
from
September 28, 2026 23:44
f504ab7 to
d290006
Compare
josemontespg
commented
Sep 29, 2026
josemontespg
force-pushed
the
react-portal-hosts-node
branch
from
September 29, 2026 19:07
d290006 to
763bf11
Compare
josemontespg
force-pushed
the
react-portal-hosts-node
branch
from
September 29, 2026 19:08
763bf11 to
3fb1325
Compare
josemontespg
changed the base branch from
react-test-dom-agnostic
to
react-implementation-types
September 29, 2026 19:09
josemontespg
force-pushed
the
react-portal-hosts-node
branch
from
September 29, 2026 19:18
3fb1325 to
acde1b4
Compare
josemontespg
commented
Sep 29, 2026
josemontespg
force-pushed
the
react-portal-hosts-node
branch
2 times, most recently
from
September 29, 2026 21:56
3718b53 to
490aa67
Compare
josemontespg
commented
Sep 30, 2026
josemontespg
force-pushed
the
react-portal-hosts-node
branch
from
September 30, 2026 19:35
e423334 to
7c8b2b5
Compare
josemontespg
changed the base branch from
react-implementation-types
to
react-markdown-renderer-bridge
September 30, 2026 20:52
josemontespg
force-pushed
the
react-portal-hosts-node
branch
from
September 30, 2026 20:53
7c8b2b5 to
048f4e7
Compare
josemontespg
force-pushed
the
react-portal-hosts-node
branch
from
September 30, 2026 21:12
048f4e7 to
5406a28
Compare
josemontespg
force-pushed
the
react-portal-hosts-node
branch
2 times, most recently
from
October 1, 2026 18:25
9c40888 to
dc2650a
Compare
josemontespg
marked this pull request as ready for review
October 1, 2026 18:30
josemontespg
force-pushed
the
react-portal-hosts-node
branch
3 times, most recently
from
October 1, 2026 20:29
1d6f38d to
1951459
Compare
andrewkolos
approved these changes
Oct 2, 2026
andrewkolos
left a comment
Collaborator
There was a problem hiding this comment.
LGTM with one concern
A catalog can mix React implementations and web component implementations: a web component parent renders React children, a React parent renders web component children, and a hand-written React entry works under either. The ReactCatalogComponent union names either kind of entry; A2uiSurface and the basic catalog are typed with it. A2uiSurface prepares the surface's catalogs once, before it creates the resolver: prepareCatalogs replaces each React entry with toWebComponent(entry), the entry plus an a2ui-react-<name> tag and an empty host element class. Every node.impl is then a WebComponentImplementation, so ChildElement renders node.impl.tagName and hands the element its node and context, as web_core's renderA2uiNode does. A React host element (display: contents) renders nothing itself. Once connected with a node it registers with its surface's HostRegistry, and A2uiSurface portals NodeContent into it from the surface's single React root, so providers, error boundaries and Suspense above A2uiSurface reach every component. The node layer is unchanged; node.id keys portals and children. BREAKING CHANGE: every catalog component renders inside a custom element; buildChild(childNode) returns that element.
React renders the content of a host it creates as the host's children, so a component's providers, error boundaries and event handlers reach the components it renders. Only hosts a Web Component creates (a Lit Column's children) are portaled, from beside the nearest React-rendered element above them, which keeps that nesting through a Web Component. Before, A2uiSurface portaled every host as a sibling, so a parent component's context did not reach its children and a React handler above the surface fired once per nested host.
Collaborator
Author
|
Thanks for the review! |
1 task done
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
The v0_9 React renderer now supports universal components.
A2uiSurfacewraps every React implementation of the surface's catalogs into aWebComponentImplementationand then renders everything as web components, usingnode(#2880), the way web_core'srenderA2uiNodeand Lit parents do. A catalog can now mix React implementations and web components from@a2ui/web_core.A React host element holds no implementation. When React creates one, React renders the node's
viewas the host's children. When a Lit parent creates one, the host registers with its surface'sHostRegistryunder the nearest React-rendered element above it, and the React content beside that element portals theviewinto it, keyed bynode.id(#2887). Everything stays in the one React root, and the React tree nests like the DOM: providers, error boundaries and event handlers of a parent component apply to the components it renders, through any Lit component in between.The one new public type is
ReactCatalogComponent(a React implementation or aWebComponentImplementation), exported from@a2ui/react/v0_9;A2uiSurfacetakes aSurfaceModel<ReactCatalogComponent>.ReactComponentImplementationand the two factories do not change.Breaking changes
<a2ui-react-<name>>withdisplay: contents, one more element per component in the DOM.Changes
catalog/prepare_catalogs.ts,catalog/to_web_component.tsx: wrap the React entries of the surface's catalogs, once per catalog; repeated names get-2,-3, ... suffixes; web component entries are kept as they are.catalog/react_host_element.ts,host_registry.ts: the host element, and the per-surface registry of the hosts Lit parents created, grouped by the React-rendered element above them.web_component_node.tsx: renders a node as its element, marks it React-rendered and hands itcontextandnode.node-view.tsx:NodeViewsplits intoChildElement(a node's element, withNodeContentas children for a React node, orHostedChildrenbeside it for a Lit node),NodeContent(a node'sview) andHostedChildren(one portal per registered host under an element).useNodeViewtakes the surface from the node's context and throws for a node without one, soadapter.tsxdrops its loading branches.A2uiSurface.tsx: prepares the catalogs and renders the root element.react_component_implementation.ts,index.ts: theReactCatalogComponentunion and its export.The second commit, "react: nest the React tree like the DOM", is the change from sibling portals to this nesting, in response to review.