--- name: mobile description: Mobile development with React Native, Flutter, and native patterns domain: development-stacks version: 1.0.0 tags: [react-native, flutter, ios, android, expo, mobile-ui] triggers: keywords: primary: [mobile, react native, flutter, ios, android, app, expo] secondary: [navigation, push notification, deep link, gesture, native module] context_boost: [app store, play store, cross-platform, hybrid] context_penalty: [web, backend, desktop, server] priority: high --- # Mobile Development ## Overview Cross-platform and native mobile development patterns, frameworks, and best practices. --- ## React Native ### Component Patterns ```tsx // Functional component with hooks import React, { useState, useCallback } from 'react'; import { View, Text, FlatList, TouchableOpacity, StyleSheet, RefreshControl, } from 'react-native'; interface User { id: string; name: string; email: string; } interface UserListProps { users: User[]; onSelect: (user: User) => void; onRefresh: () => Promise; } export function UserList({ users, onSelect, onRefresh }: UserListProps) { const [refreshing, setRefreshing] = useState(false); const handleRefresh = useCallback(async () => { setRefreshing(true); await onRefresh(); setRefreshing(false); }, [onRefresh]); const renderItem = useCallback(({ item }: { item: User }) => ( onSelect(item)} activeOpacity={0.7} > {item.name} {item.email} ), [onSelect]); const keyExtractor = useCallback((item: User) => item.id, []); return ( } ItemSeparatorComponent={() => } ListEmptyComponent={ No users found } /> ); } const styles = StyleSheet.create({ item: { padding: 16, backgroundColor: '#fff', }, name: { fontSize: 16, fontWeight: '600', color: '#1a1a1a', }, email: { fontSize: 14, color: '#666', marginTop: 4, }, separator: { height: 1, backgroundColor: '#e0e0e0', }, empty: { textAlign: 'center', padding: 32, color: '#999', }, }); ``` ### Navigation ```tsx // React Navigation setup import { NavigationContainer } from '@react-navigation/native'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; // Type-safe navigation type RootStackParamList = { Home: undefined; Profile: { userId: string }; Settings: undefined; }; type TabParamList = { Feed: undefined; Search: undefined; Notifications: undefined; Account: undefined; }; const Stack = createNativeStackNavigator(); const Tab = createBottomTabNavigator(); function TabNavigator() { return ( ({ tabBarIcon: ({ focused, color, size }) => { const iconName = { Feed: focused ? 'home' : 'home-outline', Search: focused ? 'search' : 'search-outline', Notifications: focused ? 'bell' : 'bell-outline', Account: focused ? 'person' : 'person-outline', }[route.name]; return ; }, tabBarActiveTintColor: '#007AFF', tabBarInactiveTintColor: '#8E8E93', })} > ); } function App() { return ( ); } // Using navigation in components import { useNavigation, useRoute } from '@react-navigation/native'; import type { NativeStackNavigationProp } from '@react-navigation/native-stack'; type ProfileScreenNavigationProp = NativeStackNavigationProp< RootStackParamList, 'Profile' >; function ProfileButton({ userId }: { userId: string }) { const navigation = useNavigation(); return (