This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 57).
RNHostView
A component that enables React Native views inside SwiftUI.
A component that enables proper layout behavior when React Native views are rendered inside SwiftUI components. It syncs layout information from SwiftUI back to React Native's Yoga layout system by updating the shadow node size.
When React Native views are placed inside SwiftUI components like BottomSheet, Popover or HStack and so on, the layout systems need to communicate. RNHostView bridges this gap:
- With
matchContents: The shadow node size is set to match the child React Native view's intrinsic size, allowing the SwiftUI parent to size itself based on the React Native content. - Without
matchContents: The shadow node size is set to match the parent SwiftUI view's size, allowing the React Native content to fill the available space (useful forflex: 1layouts).
Note: Pass a single React Native element as the child.
RNHostViewmeasures and lays out only its first child, so wrap several views in one parentViewand let that view arrange them.
Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
Usage
Basic usage with matchContents
Use matchContents when you want the SwiftUI parent to size itself based on the React Native content.
Flexible content without matchContents
When using flex: 1 in your React Native content, omit the matchContents prop so the content fills the available SwiftUI space.
Usage with Popover
RNHostView works well inside Popover to display interactive React Native content.
API
import { RNHostView } from '@expo/ui/swift-ui';
Component
Type: React.Element<RNHostViewProps>
boolean • Default: falseWhen true, the RNHost will update its size in the React Native view tree to match the
children's size.
When false, the RNHost will use the size of the parent SwiftUI View.
Can be only set once on mount.
(event: LayoutChangeEvent) => void