R
Rishtaara
React Native Fundamentals
Lesson 16 of 20Article12 min

Platform-Specific Code

Most RN code is cross-platform. When platforms diverge — shadows, permissions, back button — use Platform API or separate .ios.tsx / .android.tsx files.

iOS vs Android differences

Most RN code is cross-platform. When platforms diverge — shadows, permissions, back button — use Platform API or separate .ios.tsx / .android.tsx files.

Platform module
import { Platform } from "react-native";

const TAB_BAR_HEIGHT = Platform.OS === "ios" ? 88 : 64;

if (Platform.OS === "android") {
  // Android-only logic
}
Platform-specific files
Icon.ios.tsx   → used on iOS only
Icon.android.tsx → used on Android only
Icon.tsx         → fallback for both

Common platform differences

  • Shadows: shadow* props on iOS, elevation on Android.
  • Back button: Android hardware back — handle with BackHandler or React Navigation.
  • Safe areas: notches, Dynamic Island, navigation bar insets.
  • Permissions: request camera/location at runtime with react-native-permissions.