Repository navigation
Conversation
…d React Native First step to replace asChild with a render prop. Adds shared RenderProp types and an asChildToRender bridge in utils-shared, an internal useRender hook in ui-react (wrapping Base UI, with tailwind-merge on the render element className) and in ui-rnative (on the Slot merge logic, moved to utils). No component adopts it yet.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
🟡 Changes recommended
The replacement’s children overwrite component-generated children, discarding wrappers or composed content and violating the outer-element-only contract.
1 open issue
What changed in this PR
This PR lays the foundation for a consistent render prop across Lumen’s web and React Native components. It adds internal hooks and public types without migrating any components yet.
Changes:
- Add shared render-prop types and an
asChildToRendercompatibility bridge. - Introduce platform-specific hooks for composing replacement elements, props, styles, handlers, and refs.
- Extract native Slot’s merge utility and add tests, exports, and patch version plans.
| File | Description |
|---|---|
libs/utils-shared/src/lib/renderProp/renderProp.ts |
Define shared types and the compatibility bridge. |
libs/utils-shared/src/lib/renderProp/renderProp.test.tsx |
Test bridge conversion and precedence. |
libs/utils-shared/src/lib/renderProp/index.ts |
Export shared render-prop utilities. |
libs/utils-shared/src/index.ts |
Expose utilities through the package root. |
libs/ui-rnative/src/lib/utils/useRender/useRender.tsx |
Add the internal native rendering hook. |
libs/ui-rnative/src/lib/utils/useRender/useRender.test.tsx |
Test native rendering, styles, handlers, and refs. |
libs/ui-rnative/src/lib/utils/useRender/types.ts |
Define native hook and render-prop types. |
libs/ui-rnative/src/lib/utils/useRender/index.ts |
Collect internal hook exports. |
libs/ui-rnative/src/lib/utils/mergeProps/mergeProps.ts |
Extract native prop and style merging. |
libs/ui-rnative/src/lib/utils/mergeProps/mergeProps.test.ts |
Test merge precedence, handlers, and styles. |
libs/ui-rnative/src/lib/utils/mergeProps/index.ts |
Export the merge utility internally. |
libs/ui-rnative/src/lib/Components/internal/Slot/Slot.tsx |
Reuse the extracted utility without changing behavior. |
libs/ui-rnative/src/index.ts |
Publicly export native render-prop types. |
libs/ui-react/src/utils/useRender/useRender.ts |
Wrap Base UI rendering with Tailwind class merging. |
libs/ui-react/src/utils/useRender/useRender.test.tsx |
Test web rendering, classes, state, handlers, and refs. |
libs/ui-react/src/utils/useRender/types.ts |
Define web hook and render-prop types. |
libs/ui-react/src/utils/useRender/index.ts |
Collect internal hook exports. |
libs/ui-react/src/index.ts |
Publicly export web render-prop types. |
.nx/version-plans/version-plan-1796035811002-ui-rnative.md |
Schedule the native package patch release. |
.nx/version-plans/version-plan-1796035811001-ui-react.md |
Schedule the web package patch release. |
.nx/version-plans/version-plan-1796035811000-utils-shared.md |
Schedule the shared utilities patch release. |
Review effort: Balanced
|
|
||
| if (isValidElement<Record<string, unknown>>(render)) { | ||
| return cloneElement(render, { | ||
| ...mergeProps(ownProps, render.props), |
Lumen PR reportTest coverageLibs must reach 80% on every metric. Δ is against the latest green
Internals (reported, not gated)
|
📦 Dev packages publishedTarballs are hosted as assets on a per-PR GitHub pre-release and are deleted automatically when this PR is closed.
|
Web: Button family, Link, Dialog/Tooltip triggers, ListItem, Card, CardButton, Tile, MediaCard, SideBarItem, NavBarBackButton, MenuItem. React Native: the same set where it exists. Drops the @radix-ui/react-slot peer and the RN Slot, and adds the as-child-to-render migration.
|





Context
First step to deprecate the Radix
asChildpattern in favor of a Base UI–stylerenderprop, on web and React Native alike. Today Lumen mixes both: Popover, Menu and Select triggers takerender, while Button, Link, Dialog and Tooltip takeasChild. A consumer scan of 17 production repos found about 412 call sites that would userender: existingasChild, navigation in click handlers, and hand-built link wrappers.This PR only adds the abstraction. No component adopts it yet; that comes in a follow-up PR.
Technical details
utils-shared:RenderProp<Props, State>andWithRenderPropare the shared, platform-neutral types.asChildToRendermapsasChild+ child ontorender+ children. It lets the next PR keepasChildworking as a deprecated alias.ui-react:useRenderhook, a thin wrapper over@base-ui/react/use-render.classNamegoes throughcn(tailwind-merge), so a consumer class overrides a conflicting Lumen utility instead of being concatenated.ui-rnative:useRenderhook with the same contract: element or(props, state) => element, chained handlers, combined styles (including Pressable style functions), merged refs. Default component isPressable.mergeProps/combineStylesmoved tolib/utils/mergeProps, because the layer rules forbid utils importing fromComponents/.Slot.tsxnow imports it, with no behavior change.RenderProp,WithRenderProp) are exported fromui-reactandui-rnative. The hooks stay internal.return useRender({ defaultTagName: 'button', render, ref, state, props }). No wrapper component.Start reviewing at
libs/ui-react/src/utils/useRender/useRender.tsandlibs/ui-rnative/src/lib/utils/useRender/useRender.tsx.How to test
CI covers it. Locally, run
npx nx run-many -t lint typecheck test --projects=@ledgerhq/lumen-utils-shared,@ledgerhq/lumen-ui-react,@ledgerhq/lumen-ui-rnativeandnpm run check:layers.Follow-ups
renderin BaseButton (Button, IconButton, MediaButton, TileButton), Link and ListItem, and deprecateasChildthroughasChildToRender.renderconvention in thecomponent-architectureskill.Update: render applied, asChild removed
This PR now also applies
renderto every component that scored 2+ in the consumer study, and removesasChildentirely (breaking, covered by theas-child-to-rendermigration).render).DialogContent.asChildis removed with no replacement.useRenderbuilds the element and Radix's trigger merges onto it with an internalasChild. Moving those primitives to Base UI is a separate change.TooltipTriggerandBaseCheckboxloseasChild, and the internalSlotis deleted (mergePropsstays).@radix-ui/react-slotis no longer a peer ofui-react.RenderProp/WithRenderProptypes. TheasChildToRenderbridge is gone.render, Lumen components keep their own content (icon, spinner, label, the Link external icon plustarget/rel). Triggers take the whole element, asMenuTriggeralready does:render={<Button>Open</Button>}.