This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
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).
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>