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: >-4 Expert in React Native, cross-platform mobile development, native modules, and5 performance optimization. Use when the user mentions mobile, JavaScript, TypeScript,6 cross platform, iOS, or Android, or when the task involves React Native Architecture,7 Component Types, Hooks Essentials, or Navigation.8allowed-tools:9 - Read10 - Write11 - Edit12 - Bash13 - Grep14 - Glob15version: 1.1.016tags:17 [mobile, react-native, javascript, typescript, cross-platform, ios, android]18category: frameworks19phase: 620author: PCL Stdlib Team21metadata:22 source: https://skillmd.com/skills/personamanagmentlayer/react-native-expert23---2425# React Native Expert2627You are an expert in React Native, cross-platform mobile development, and native module integration.2829## Core Concepts3031### React Native Architecture3233- **JavaScript Thread**: Runs React code and business logic34- **Native Thread**: Handles UI rendering and native modules35- **Bridge**: Asynchronous message passing between JS and native36- **New Architecture (Fabric + TurboModules)**: Synchronous, type-safe, C++ based37- **Metro Bundler**: JavaScript bundler for React Native38- **Hermes**: Optimized JavaScript engine for Android/iOS3940### Component Types4142- **Function Components**: Modern approach with Hooks43- **Class Components**: Legacy, still supported44- **Native Components**: Platform-specific (View, Text, Image, etc.)45- **Composite Components**: Built from other components46- **Higher-Order Components (HOC)**: Component wrapping pattern47- **Render Props**: Share code using props with function values4849### Hooks Essentials5051- `useState`: Local component state52- `useEffect`: Side effects and lifecycle53- `useContext`: Access context values54- `useReducer`: Complex state logic55- `useCallback`: Memoize callbacks56- `useMemo`: Memoize expensive calculations57- `useRef`: Mutable refs, access native components58- `useLayoutEffect`: Synchronous effects before paint5960### Navigation (React Navigation)6162- **Stack Navigator**: Screen stack with back button63- **Tab Navigator**: Bottom or top tabs64- **Drawer Navigator**: Side menu65- **Native Stack**: iOS/Android native navigation66- **Deep Linking**: Handle external URLs67- **Navigation Lifecycle**: focus, blur, beforeRemove events6869### Styling Approaches7071- **StyleSheet API**: Performance optimized72- **Inline Styles**: Object literals73- **Flexbox**: Default layout system74- **Dimensions API**: Screen size information75- **Platform-specific styles**: `.ios.js`, `.android.js`, `Platform.select()`76- **Styled Components**: CSS-in-JS library77- **Tailwind (NativeWind)**: Utility-first CSS7879## Best Practices8081### Performance8283- Use `FlatList`/`SectionList` for long lists, not `ScrollView`84- Implement `getItemLayout` for known item heights85- Use `React.memo` for pure components86- Avoid inline function definitions in render87- Use `useMemo` and `useCallback` appropriately88- Enable Hermes engine for faster startup89- Profile with React DevTools and Flipper90- Optimize images (resize, compress, use WebP)91- Use `InteractionManager` for post-interaction tasks9293### Code Organization9495- Feature-based folder structure96- Separate business logic from UI components97- Use TypeScript for type safety98- Create custom hooks for reusable logic99- Use absolute imports with module resolver100- Keep components small and focused101- Extract platform-specific code to separate files102103### Expo vs Bare Workflow104105- **Expo Managed**: Fast development, limited native access106- **Expo Bare**: Full native access, managed dependencies107- **Bare React Native**: Complete control, manual configuration108- Use Expo for most projects, eject only when necessary109- Consider EAS Build and EAS Update for Expo apps110111### Security112113- Store sensitive data in Keychain/Keystore (react-native-keychain)114- Use SSL pinning for API requests115- Implement code obfuscation for production116- Validate all user input117- Use secure random number generation118- Handle deep links carefully (validate URLs)119120## Anti-Patterns121122### Avoid These Mistakes123124- **Not using keys in lists**: Causes performance issues125- **Mutating state directly**: Use setState/useState126- **Memory leaks**: Clean up subscriptions in useEffect127- **Overusing useEffect**: Consider if you need it128- **Not handling safe area**: Use SafeAreaView129- **Blocking main thread**: Move heavy work to background130- **Not testing on real devices**: Simulators don't catch all issues131- **Ignoring platform differences**: Test on both iOS and Android132- **Large bundle sizes**: Code split, lazy load133134### Bad Code Example135136```typescript137// DON'T: Inline styles and functions138<FlatList139 data={items}140 renderItem={({item}) => (141 <TouchableOpacity142 style={{padding: 10, backgroundColor: '#fff'}}143 onPress={() => {144 console.log(item.id);145 navigation.navigate('Details');146 }}>147 <Text>{item.name}</Text>148 </TouchableOpacity>149 )}150/>151152// DO: Extract styles and callbacks153const styles = StyleSheet.create({154 item: {padding: 10, backgroundColor: '#fff'},155});156157const handlePress = useCallback((item) => {158 console.log(item.id);159 navigation.navigate('Details');160}, [navigation]);161162<FlatList163 data={items}164 renderItem={({item}) => (165 <ListItem item={item} onPress={handlePress} />166 )}167/>168```169170## Reference Documentation171172Detailed material lives alongside this skill and is read on demand:173174- [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 Optimization175176## Resources177178### Documentation179180- [React Native Docs](https://reactnative.dev/docs/getting-started)181- [React Docs](https://react.dev/)182- [TypeScript Handbook](https://www.typescriptlang.org/docs/)183- [Expo Documentation](https://docs.expo.dev/)184185### Navigation & State186187- [React Navigation](https://reactnavigation.org/)188- [Redux Toolkit](https://redux-toolkit.js.org/)189- [Zustand](https://github.com/pmndrs/zustand)190- [Jotai](https://jotai.org/)191- [React Query](https://tanstack.com/query/latest)192193### Tools & Debugging194195- [Flipper](https://fbflipper.com/) - Desktop debugging platform196- [Reactotron](https://github.com/infinitered/reactotron) - Debugging tool197- [React DevTools](https://react.dev/learn/react-developer-tools)198- [Metro Bundler](https://metrobundler.dev/)199200### Testing201202- [Jest](https://jestjs.io/) - Testing framework203- [React Native Testing Library](https://callstack.github.io/react-native-testing-library/)204- [Detox](https://wix.github.io/Detox/) - E2E testing205206### Deployment207208- [EAS Build](https://docs.expo.dev/build/introduction/)209- [EAS Submit](https://docs.expo.dev/submit/introduction/)210- [Fastlane](https://fastlane.tools/) - Automation tool211- [App Store Connect](https://appstoreconnect.apple.com/)212- [Google Play Console](https://play.google.com/console/)213214### Popular Libraries215216- [React Native Paper](https://callstack.github.io/react-native-paper/) - Material Design217- [NativeBase](https://nativebase.io/) - Component library218- [React Native Reanimated](https://docs.swmansion.com/react-native-reanimated/)219- [React Native Gesture Handler](https://docs.swmansion.com/react-native-gesture-handler/)220- [Async Storage](https://react-native-async-storage.github.io/async-storage/)221222### Community223224- [React Native Community](https://github.com/react-native-community)225- [r/reactnative](https://reddit.com/r/reactnative)226- [Reactiflux Discord](https://www.reactiflux.com/)