Jetpack Compose
用于借助 @expo/ui 构建原生 Android 界面的 Jetpack Compose 组件。
Android
For the complete documentation index, see llms.txt. Use this Use this file to discover all available pages.
@expo/ui/jetpack-compose 中的 Jetpack Compose 组件允许你从 React Native 使用 Jetpack Compose 构建完全原生的 Android 界面。
安装
Terminal
- npx expo install @expo/uiIf you are installing this in an existing React Native app, make sure to install expo in your project.
用法
使用 @expo/ui/jetpack-compose 中的组件需要将其包装在一个 Host 组件中。Host 是 Jetpack Compose 视图的容器。
import { Host, Button } from '@expo/ui/jetpack-compose'; export function SaveButton() { return ( <Host matchContents> <Button onClick={() => alert('Saved!')}>保存更改</Button> </Host> ); }