组件与接口
React-native
提供了大量的内置组件,你可以在左侧的导航栏找到完整的组件及接口列表,如果你不确定从何处开始,那么请浏览接下来的内容:
您不必只使用React Native
原生的组件和 API。React Native
是由数千名开发人员组成的社区。 如果您正在寻找一个特定库,请在npm
中搜索提到react-native的包,或查看Awesome React Native获取相关信息。
基础组件 Basic Components
绝大多数的 APP 都会使用这些基础组件,如果你是一个 RN 的新手,请先熟悉下列基础组件:
View
The most fundamental component for building a UI.
Text
A component for displaying text.
Image
A component for displaying images.
TextInput
A component for inputting text into the app via a keyboard.
ScrollView
Provides a scrolling container that can host multiple components and views.
StyleSheet
Provides an abstraction layer similar to CSS stylesheets.
用户界面 User Interface
使用以下组件在任何平台上呈现通用用户界面控件。 对于平台特定的组件,请阅读后续内容
Button
A basic button component for handling touches that should render nicely on any platform.
Picker
Renders the native picker component on iOS and Android.
Slider
A component used to select a single value from a range of values.
Switch
Renders a boolean input.
列表视图 List Views
与更为通用的组件ScrollView
不同的是,下列组件都只会渲染显示在屏幕上的内容(译者注:可类比于懒加载),这使得它们更适用于长列表的展示。
FlatList
A component for rendering performant scrollable lists.
SectionList
Like FlatList
, but for sectioned lists.
ios 组件和接口 iOS Components and APIs
以下众多的组件为常见的 UIKit 类提供了二次包装。
ActionSheetIOS
API to display an iOS action sheet or share sheet.
AlertIOS
Create an iOS alert dialog with a message or create a prompt for user input.
DatePickerIOS
Renders a date/time picker (selector) on iOS.
ImagePickerIOS
Renders a image picker on iOS.
NavigatorIOS
A wrapper around UINavigationController
, enabling you to implement a navigation stack.
ProgressViewIOS
Renders a UIProgressView
on iOS.
PushNotificationIOS
Handle push notifications for your app, including permission handling and icon badge number.
SegmentedControlIOS
Renders a UISegmentedControl
on iOS.
TabBarIOS
Renders a UITabViewController
on iOS. Use with TabBarIOS.Item.
Android Components and APIs
以下众多的组件为常见的安卓类提供了二次包装。
BackHandler
Detect hardware button presses for back navigation.
DatePickerAndroid
Opens the standard Android date picker dialog.
DrawerLayoutAndroid
Renders a DrawerLayout
on Android.
PermissionsAndroid
Provides access to the permissions model introduced in Android M.
ProgressBarAndroid
Renders a ProgressBar
on Android.
TimePickerAndroid
Opens the standard Android time picker dialog.
ToastAndroid
Create an Android Toast alert.
ToolbarAndroid
Renders a Toolbar
on Android.
ViewPagerAndroid
Container that allows to flip left and right between child views.
Others
These components may come in handy for certain applications. For an exhaustive list of components and APIs, check out the sidebar to the left.
下列的组件可能在某些应用中派上用场,在左侧导航栏中你可以找到详细的组件及接口列表。
ActivityIndicator
Displays a circular loading indicator.
Alert
Launches an alert dialog with the specified title and message.
Animated
A library for creating fluid, powerful animations that are easy to build and maintain.
CameraRoll
Provides access to the local camera roll / gallery.
Clipboard
Provides an interface for setting and getting content from the clipboard on both iOS and Android.
Dimensions
Provides an interface for getting device dimensions.
KeyboardAvoidingView
Provides a view that moves out of the way of the virtual keyboard automatically.
Linking
Provides a general interface to interact with both incoming and outgoing app links.
Modal
Provides a simple way to present content above an enclosing view.
PixelRatio
Provides access to the device pixel density.
RefreshControl
This component is used inside a ScrollView
to add pull to refresh functionality.
StatusBar
Component to control the app status bar.
WebView
A component that renders web content in a native view.