AGENT SKILL
react-native-platform-specific
Handling iOS and Android differences with Platform API and native modules. Use when handling platform-specific behavior or integrating native modules in React Native. (triggers: **/*.tsx, **/*.ts, **/*.ios.*, **/*.android.*, Platform, Platform.select, native-module, ios, android)
- License 许可
- MIT
- 最近更新
- 2026-06-24
- Stars
- ★ 67
- Forks
- 24
01 前言 Front Matter
- name
- react-native-platform-specific
- description
- Handling iOS and Android differences with Platform API and native modules. Use when handling platform-specific behavior or integrating native modules in React Native. (triggers: **/*.tsx, **/*.ts, **/*.ios.*, **/*.android.*, Platform, Platform.select, native-module, ios, android)
02 资源文件 8
- 参考文档agents/openai.yaml242 B
- 参考文档references/code-smells.md3.7 KB
- 参考文档references/demystify-swiftui-performance-wwdc23.md1.8 KB
- 参考文档references/optimizing-swiftui-performance-instruments.md1.8 KB
- 参考文档references/profiling-intake.md1.9 KB
- 参考文档references/report-template.md1.2 KB
- 参考文档references/understanding-hangs-in-your-app.md1.2 KB
- 参考文档references/understanding-improving-swiftui-performance.md2.2 KB
03 SKILL.md 正文
React Native Platform-Specific Code
Priority: P1 (OPERATIONAL)
File Extensions
Use .ios. and .android. for platform-specific files:
Button.tsx # Shared
Button.ios.tsx # iOS-specific
Button.android.tsx # Android-specific
React Native automatically picks the right file:
- iOS: Button.ios.tsx → Button.tsx (fallback)
- Android: Button.android.tsx → Button.tsx (fallback)
Native Modules
- Expo: Use Expo modules when available (
expo-*packages). - Bare RN: Use community modules (
@react-native-community/*). - Custom: Write native modules in Swift/Kotlin when needed.
Anti-Patterns
- No Excessive Branching: Extract to separate files if logic diverges.
- No Hardcoded Version Checks: Use feature detection.
- No Ignoring Android: Test on both platforms.
References
See references/native-modules.md for Platform detection examples, Native Bridge (iOS/Android), Expo JSI Modules, and SafeArea handling.