This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
RN主机视图
一个跨平台组件,用于在 @expo/ui 视图中承载 React Native 视图。
在通用 @expo/ui 布局中托管 React Native 视图子树。在 Android 和 iOS 上,它重新导出平台原生的 RNHostView 用于 Jetpack Compose/RNHostView 用于 SwiftUI,因此 React Native 子组件可以桥接到周围的 Compose/SwiftUI 树中。在 Web 上,没有原生宿主树可供桥接,因此它回退到封装子组件的 React Native View。
🌐 Hosts a React Native view subtree inside a universal @expo/ui layout. On Android and iOS, it re-exports the platform-native RNHostView for Jetpack Compose/RNHostView for SwiftUI, so React Native children bridge into the surrounding Compose/SwiftUI tree. On web, there is no native host tree to bridge into, so it falls back to a React Native View that wraps the children.
注意: 传入一个单独的 React Native 元素作为子元素。
RNHostView只会测量和布局它的第一个子元素,所以如果有多个视图,先用一个父View封装它们,让这个父视图来安排布局。


安装
🌐 Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
🌐 Usage
基本用法
🌐 Basic usage
将 React Native 视图子树放置在通用 @expo/ui 布局中的任何位置。
🌐 Place a React Native view subtree anywhere inside a universal @expo/ui layout.
填充父级 vs. 匹配子级
🌐 Fill parent vs. match child
默认情况下,RNHostView 会填充其原生父级。将 matchContents 设置为让它缩小以适应其 React Native 子组件。
🌐 By default RNHostView fills its native parent. Set matchContents to have it shrink to fit its React Native children instead.
应用接口
🌐 API
import { RNHostView } from '@expo/ui';
No API data file found, sorry!