Skip to main content
Native UI components allow you to integrate native views into your React Native application, providing access to platform-specific UI elements and optimized rendering.

What are Native UI Components?

Native UI components are platform-specific views (Android Views or iOS UIViews) that are wrapped and exposed to React Native. They allow you to:
  • Use platform-specific UI widgets
  • Optimize performance for complex views
  • Integrate existing native UI libraries
  • Access native UI features not available in React Native

Architecture

Native UI components consist of:
  1. View Manager: Creates and manages native view instances
  2. View Implementation: The actual native view code
  3. Props: Properties that can be set from JavaScript
  4. Events: Callbacks that send data back to JavaScript

Android Native UI Components

Creating a View Manager

Registering the View Manager

Add to your ReactPackage:

Using in JavaScript

iOS Native UI Components

Creating a View Manager

View Properties

Android Property Types

Use @ReactProp annotation to expose properties:

iOS Property Macros

Handling Events

Android Events

JavaScript usage:

iOS Events

Example: Activity Indicator View Manager

Here’s a real-world example from React Native’s source code (packages/react-native/React/Views/RCTActivityIndicatorViewManager.m:28-63):

Advanced Topics

View Lifecycle

Android

iOS

Commands

Expose imperative methods that can be called from JavaScript:

Android

iOS

JavaScript usage:

TypeScript Support

Create type-safe interfaces for your native components:

Best Practices

  • Keep view managers focused on view creation and property mapping
  • Use events for data flowing from native to JavaScript
  • Use props for data flowing from JavaScript to native
  • Clean up resources in lifecycle methods
  • Implement proper error handling
  • Document your component’s API and props
  • Consider performance implications of frequent prop updates
  • Test on both platforms when building cross-platform components
  • Use TypeScript for better type safety
  • Follow platform-specific design guidelines