Jetpack 组合

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

Android
Bundled version:
~55.0.2

重要 该库目前处于 alpha 版本,并且会经常发生重大更改。 它在 Expo Go 应用中不可用 — 请使用 开发版本 来试用。

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

🌐 The Jetpack Compose components in @expo/ui/jetpack-compose allow you to build fully native Android interfaces using Jetpack Compose from React Native.

安装

🌐 Installation

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.

用法

🌐 Usage

使用 @expo/ui/jetpack-compose 的组件需要将其封装在 Host 组件中。Host 是 Jetpack Compose 视图的容器。

🌐 Using a component from @expo/ui/jetpack-compose requires wrapping it in a Host component. The Host is a container for Jetpack Compose views.

import { Host, Button } from '@expo/ui/jetpack-compose'; export function SaveButton() { return ( <Host matchContents> <Button onPress={() => alert('Saved!')}>Save changes</Button> </Host> ); }