react-native
React Native mobile development. Core components, navigation (React Navigation), platform-specific code, native modules, performance optimization, and debugging. USE WHEN: user mentions "React Native", "react-native", "mobile app with React", "cross-platform mobile", "RN", "react-native-cli" DO NOT USE FOR: Expo-specific features - use `expo`; Flutter - use `flutter`; web React - use `react` skills
What this skill does
# React Native
## Core Components
```tsx
import { View, Text, ScrollView, FlatList, Pressable, StyleSheet } from 'react-native';
function ProductList({ products }: { products: Product[] }) {
return (
<FlatList
data={products}
keyExtractor={(item) => item.id}
renderItem={({ item }) => (
<Pressable onPress={() => navigate('Detail', { id: item.id })} style={styles.card}>
<Text style={styles.title}>{item.name}</Text>
<Text style={styles.price}>${item.price}</Text>
</Pressable>
)}
ItemSeparatorComponent={() => <View style={styles.separator} />}
/>
);
}
const styles = StyleSheet.create({
card: { padding: 16, backgroundColor: '#fff' },
title: { fontSize: 16, fontWeight: '600' },
price: { fontSize: 14, color: '#666', marginTop: 4 },
separator: { height: 1, backgroundColor: '#eee' },
});
```
## Navigation (React Navigation)
```tsx
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
type RootStackParamList = {
Home: undefined;
Detail: { id: string };
};
const Stack = createNativeStackNavigator<RootStackParamList>();
const Tab = createBottomTabNavigator();
function App() {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Detail" component={DetailScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}
// Type-safe navigation
import { NativeStackScreenProps } from '@react-navigation/native-stack';
type DetailProps = NativeStackScreenProps<RootStackParamList, 'Detail'>;
function DetailScreen({ route, navigation }: DetailProps) {
const { id } = route.params;
return <Text>{id}</Text>;
}
```
## Platform-Specific Code
```tsx
import { Platform } from 'react-native';
const styles = StyleSheet.create({
shadow: Platform.select({
ios: { shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.1 },
android: { elevation: 3 },
}),
});
// File-based: Component.ios.tsx / Component.android.tsx (auto-resolved)
```
## Networking
```tsx
import { useQuery, useMutation } from '@tanstack/react-query';
function useProducts() {
return useQuery({
queryKey: ['products'],
queryFn: async () => {
const res = await fetch(`${API_URL}/products`);
if (!res.ok) throw new Error('Failed to fetch');
return res.json() as Promise<Product[]>;
},
});
}
```
## Secure Storage
```tsx
import EncryptedStorage from 'react-native-encrypted-storage';
await EncryptedStorage.setItem('auth_token', token);
const token = await EncryptedStorage.getItem('auth_token');
await EncryptedStorage.removeItem('auth_token');
```
## Performance
| Technique | Impact |
|-----------|--------|
| `FlatList` over `ScrollView` for lists | High |
| `React.memo` on list items | Medium |
| `useCallback` for event handlers in lists | Medium |
| Hermes engine (default in RN 0.70+) | High |
| Avoid inline styles in render | Low-Medium |
| `InteractionManager.runAfterInteractions` | Medium |
## Anti-Patterns
| Anti-Pattern | Fix |
|--------------|-----|
| ScrollView for long lists | Use FlatList or FlashList |
| Inline functions in FlatList renderItem | Extract component, use React.memo |
| Storing tokens in AsyncStorage | Use react-native-encrypted-storage |
| No error boundaries | Wrap screens in error boundaries |
| Ignoring keyboard on forms | Use KeyboardAvoidingView |
## Production Checklist
- [ ] Hermes engine enabled
- [ ] ProGuard/R8 for Android release builds
- [ ] App signing configured (Android keystore, iOS certificates)
- [ ] Deep linking configured
- [ ] Error tracking (Sentry, Bugsnag)
- [ ] OTA updates (CodePush or Expo Updates)
- [ ] Performance monitoring (Flipper, React DevTools)
Related in Web Dev
generating-lwc-components
IncludedLightning Web Components with PICKLES methodology and 165-point scoring. Use this skill when the user creates or edits LWC components, builds wire service patterns, or writes Jest tests for LWC. TRIGGER when: user creates/edits LWC components, touches lwc/**/*.js, .html, .css, .js-meta.xml files, or asks about wire service, SLDS, or Jest LWC tests. DO NOT TRIGGER when: Apex classes (use generating-apex), Aura components, or Visualforce.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Set up queries with useQuery, mutations with useMutation, configure QueryClient caching strategies, implement optimistic updates, and handle infinite scroll with useInfiniteQuery. Use when: setting up data fetching in React projects, migrating from v4 to v5, or fixing object syntax required errors, query callbacks removed issues, cacheTime renamed to gcTime, isPending vs isLoading confusion, keepPreviousData removed problems.
document-processor-api
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
nutrient-document-processing
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Covers useMutationState, simplified optimistic updates, throwOnError, network mode (offline/PWA), and infiniteQueryOptions. Use when setting up data fetching, fixing v4→v5 migration errors (object syntax, gcTime, isPending, keepPreviousData), or debugging SSR/hydration issues with streaming server components.
accelint-nextjs-best-practices
IncludedNext.js performance optimization and best practices. Use when writing Next.js code (App Router or Pages Router); implementing Server Components, Server Actions, or API routes; optimizing RSC serialization, data fetching, or server-side rendering; reviewing Next.js code for performance issues; fixing authentication in Server Actions; or implementing Suspense boundaries, parallel data fetching, or request deduplication.