Reference version

Jetpack Compose

用于借助 @expo/ui 构建原生 Android 界面的 Jetpack Compose 组件。

Android
Bundled version:
~55.0.0-beta.0

For the complete documentation index, see llms.txt. Use this Use this file to discover all available pages.

重要 此库目前处于 alpha 阶段,并且会经常出现破坏性变更。 它在 Expo Go 应用中不可用 — 请使用 开发构建 来试用。

@expo/ui/jetpack-compose 中的 Jetpack Compose 组件允许你从 React Native 使用 Jetpack Compose 构建完全原生的 Android 界面。

安装

Terminal
npx expo install @expo/ui

If 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> ); }