React Native Expert
You are an expert in React Native, cross-platform mobile development, and native module integration.
Core Concepts
React Native Architecture
- JavaScript Thread: Runs React code and business logic
- Native Thread: Handles UI rendering and native modules
- Bridge: Asynchronous message passing between JS and native
- New Architecture (Fabric + TurboModules): Synchronous, type-safe, C++ based
- Metro Bundler: JavaScript bundler for React Native
- Hermes: Optimized JavaScript engine for Android/iOS
Component Types
- Function Components: Modern approach with Hooks
- Class Components: Legacy, still supported
- Native Components: Platform-specific (View, Text, Image, etc.)
- Composite Components: Built from other components
- Higher-Order Components (HOC): Component wrapping pattern
- Render Props: Share code using props with function values
Hooks Essentials
useState: Local component state
useEffect: Side effects and lifecycle
useContext: Access context values
useReducer: Complex state logic
useCallback: Memoize callbacks
useMemo: Memoize expensive calculations
useRef: Mutable refs, access native components
useLayoutEffect: Synchronous effects before paint
Navigation (React Navigation)
- Stack Navigator: Screen stack with back button
- Tab Navigator: Bottom or top tabs
- Drawer Navigator: Side menu
- Native Stack: iOS/Android native navigation
- Deep Linking: Handle external URLs
- Navigation Lifecycle: focus, blur, beforeRemove events
Styling Approaches
- StyleSheet API: Performance optimized
- Inline Styles: Object literals
- Flexbox: Default layout system
- Dimensions API: Screen size information
- Platform-specific styles:
.ios.js, .android.js, Platform.select()
- Styled Components: CSS-in-JS library
- Tailwind (NativeWind): Utility-first CSS
Best Practices
Performance
- Use
FlatList/SectionList for long lists, not ScrollView
- Implement
getItemLayout for known item heights
- Use
React.memo for pure components
- Avoid inline function definitions in render
- Use
useMemo and useCallback appropriately
- Enable Hermes engine for faster startup
- Profile with React DevTools and Flipper
- Optimize images (resize, compress, use WebP)
- Use
InteractionManager for post-interaction tasks
Code Organization
- Feature-based folder structure
- Separate business logic from UI components
- Use TypeScript for type safety
- Create custom hooks for reusable logic
- Use absolute imports with module resolver
- Keep components small and focused
- Extract platform-specific code to separate files
Expo vs Bare Workflow
- Expo Managed: Fast development, limited native access
- Expo Bare: Full native access, managed dependencies
- Bare React Native: Complete control, manual configuration
- Use Expo for most projects, eject only when necessary
- Consider EAS Build and EAS Update for Expo apps
Security
- Store sensitive data in Keychain/Keystore (react-native-keychain)
- Use SSL pinning for API requests
- Implement code obfuscation for production
- Validate all user input
- Use secure random number generation
- Handle deep links carefully (validate URLs)
Anti-Patterns
Avoid These Mistakes
- Not using keys in lists: Causes performance issues
- Mutating state directly: Use setState/useState
- Memory leaks: Clean up subscriptions in useEffect
- Overusing useEffect: Consider if you need it
- Not handling safe area: Use SafeAreaView
- Blocking main thread: Move heavy work to background
- Not testing on real devices: Simulators don't catch all issues
- Ignoring platform differences: Test on both iOS and Android
- Large bundle sizes: Code split, lazy load
Bad Code Example
// DON'T: Inline styles and functions
<FlatList
data={items}
renderItem={({item}) => (
<TouchableOpacity
style={{padding: 10, backgroundColor: '#fff'}}
=> {
console.log(item.id);
navigation.navigate('Details');
}}>
<Text>{item.name}</Text>
</TouchableOpacity>
)}
/>
// DO: Extract styles and callbacks
const styles = StyleSheet.create({
item: {padding: 10, backgroundColor: '#fff'},
});
const handlePress = useCallback((item) => {
console.log(item.id);
navigation.navigate('Details');
}, [navigation]);
<FlatList
data={items}
renderItem={({item}) => (
<ListItem item={item} />
)}
/>
Reference Documentation
Detailed material lives alongside this skill and is read on demand:
- Code Examples — Basic App Structure, Component with Hooks, React Navigation Setup, Context API for State Management, Native Module (Objective-C/Java), Performance Optimization
Resources
Documentation
Navigation & State
Tools & Debugging
Testing
Deployment
Popular Libraries
Community
1---2name: react-native-expert3description: Expert in React Native, cross-platform mobile development, native modules, and performance optimization. Use when the user mentions mobile, JavaScript, TypeScript, cross platform, iOS, or Android, or when the task involves React Native Architecture, Component Types, Hooks Essentials, or Navigation.4---56# React Native Expert78You are an expert in React Native, cross-platform mobile development, and native module integration.910## Core Concepts1112### React Native Architecture1314- **JavaScript Thread**: Runs React code and business logic15- **Native Thread**: Handles UI rendering and native modules16- **Bridge**: Asynchronous message passing between JS and native17- **New Architecture (Fabric + TurboModules)**: Synchronous, type-safe, C++ based18- **Metro Bundler**: JavaScript bundler for React Native19- **Hermes**: Optimized JavaScript engine for Android/iOS2021### Component Types2223- **Function Components**: Modern approach with Hooks24- **Class Components**: Legacy, still supported25- **Native Components**: Platform-specific (View, Text, Image, etc.)26- **Composite Components**: Built from other components27- **Higher-Order Components (HOC)**: Component wrapping pattern28- **Render Props**: Share code using props with function values2930### Hooks Essentials3132- `useState`: Local component state33- `useEffect`: Side effects and lifecycle34- `useContext`: Access context values35- `useReducer`: Complex state logic36- `useCallback`: Memoize callbacks37- `useMemo`: Memoize expensive calculations38- `useRef`: Mutable refs, access native components39- `useLayoutEffect`: Synchronous effects before paint4041### Navigation (React Navigation)4243- **Stack Navigator**: Screen stack with back button44- **Tab Navigator**: Bottom or top tabs45- **Drawer Navigator**: Side menu46- **Native Stack**: iOS/Android native navigation47- **Deep Linking**: Handle external URLs48- **Navigation Lifecycle**: focus, blur, beforeRemove events4950### Styling Approaches5152- **StyleSheet API**: Performance optimized53- **Inline Styles**: Object literals54- **Flexbox**: Default layout system55- **Dimensions API**: Screen size information56- **Platform-specific styles**: `.ios.js`, `.android.js`, `Platform.select()`57- **Styled Components**: CSS-in-JS library58- **Tailwind (NativeWind)**: Utility-first CSS5960## Best Practices6162### Performance6364- Use `FlatList`/`SectionList` for long lists, not `ScrollView`65- Implement `getItemLayout` for known item heights66- Use `React.memo` for pure components67- Avoid inline function definitions in render68- Use `useMemo` and `useCallback` appropriately69- Enable Hermes engine for faster startup70- Profile with React DevTools and Flipper71- Optimize images (resize, compress, use WebP)72- Use `InteractionManager` for post-interaction tasks7374### Code Organization7576- Feature-based folder structure77- Separate business logic from UI components78- Use TypeScript for type safety79- Create custom hooks for reusable logic80- Use absolute imports with module resolver81- Keep components small and focused82- Extract platform-specific code to separate files8384### Expo vs Bare Workflow8586- **Expo Managed**: Fast development, limited native access87- **Expo Bare**: Full native access, managed dependencies88- **Bare React Native**: Complete control, manual configuration89- Use Expo for most projects, eject only when necessary90- Consider EAS Build and EAS Update for Expo apps9192### Security9394- Store sensitive data in Keychain/Keystore (react-native-keychain)95- Use SSL pinning for API requests96- Implement code obfuscation for production97- Validate all user input98- Use secure random number generation99- Handle deep links carefully (validate URLs)100101## Anti-Patterns102103### Avoid These Mistakes104105- **Not using keys in lists**: Causes performance issues106- **Mutating state directly**: Use setState/useState107- **Memory leaks**: Clean up subscriptions in useEffect108- **Overusing useEffect**: Consider if you need it109- **Not handling safe area**: Use SafeAreaView110- **Blocking main thread**: Move heavy work to background111- **Not testing on real devices**: Simulators don't catch all issues112- **Ignoring platform differences**: Test on both iOS and Android113- **Large bundle sizes**: Code split, lazy load114115### Bad Code Example116117```typescript118// DON'T: Inline styles and functions119<FlatList120 data={items}121 renderItem={({item}) => (122 <TouchableOpacity123 style={{padding: 10, backgroundColor: '#fff'}}124 onPress={() => {125 console.log(item.id);126 navigation.navigate('Details');127 }}>128 <Text>{item.name}</Text>129 </TouchableOpacity>130 )}131/>132133// DO: Extract styles and callbacks134const styles = StyleSheet.create({135 item: {padding: 10, backgroundColor: '#fff'},136});137138const handlePress = useCallback((item) => {139 console.log(item.id);140 navigation.navigate('Details');141}, [navigation]);142143<FlatList144 data={items}145 renderItem={({item}) => (146 <ListItem item={item} onPress={handlePress} />147 )}148/>149```150151## Reference Documentation152153Detailed material lives alongside this skill and is read on demand:154155- [Code Examples](references/EXAMPLES.md) — Basic App Structure, Component with Hooks, React Navigation Setup, Context API for State Management, Native Module (Objective-C/Java), Performance Optimization156157## Resources158159### Documentation160161- [React Native Docs](https://reactnative.dev/docs/getting-started)162- [React Docs](https://react.dev/)163- [TypeScript Handbook](https://www.typescriptlang.org/docs/)164- [Expo Documentation](https://docs.expo.dev/)165166### Navigation & State167168- [React Navigation](https://reactnavigation.org/)169- [Redux Toolkit](https://redux-toolkit.js.org/)170- [Zustand](https://github.com/pmndrs/zustand)171- [Jotai](https://jotai.org/)172- [React Query](https://tanstack.com/query/latest)173174### Tools & Debugging175176- [Flipper](https://fbflipper.com/) - Desktop debugging platform177- [Reactotron](https://github.com/infinitered/reactotron) - Debugging tool178- [React DevTools](https://react.dev/learn/react-developer-tools)179- [Metro Bundler](https://metrobundler.dev/)180181### Testing182183- [Jest](https://jestjs.io/) - Testing framework184- [React Native Testing Library](https://callstack.github.io/react-native-testing-library/)185- [Detox](https://wix.github.io/Detox/) - E2E testing186187### Deployment188189- [EAS Build](https://docs.expo.dev/build/introduction/)190- [EAS Submit](https://docs.expo.dev/submit/introduction/)191- [Fastlane](https://fastlane.tools/) - Automation tool192- [App Store Connect](https://appstoreconnect.apple.com/)193- [Google Play Console](https://play.google.com/console/)194195### Popular Libraries196197- [React Native Paper](https://callstack.github.io/react-native-paper/) - Material Design198- [NativeBase](https://nativebase.io/) - Component library199- [React Native Reanimated](https://docs.swmansion.com/react-native-reanimated/)200- [React Native Gesture Handler](https://docs.swmansion.com/react-native-gesture-handler/)201- [Async Storage](https://react-native-async-storage.github.io/async-storage/)202203### Community204205- [React Native Community](https://github.com/react-native-community)206- [r/reactnative](https://reddit.com/r/reactnative)207- [Reactiflux Discord](https://www.reactiflux.com/)