react-native
Cross-platform mobile development with React Native and Expo. Use when building iOS/Android apps with JavaScript/TypeScript, implementing native features, or optimizing mobile performance.
What this skill does
# React Native Development
Build native iOS and Android apps with React Native and Expo.
## Framework Options
| Framework | Use When |
| ------------------------ | ----------------------------------------------- |
| **Expo** (Recommended) | Most apps, faster development, managed workflow |
| **React Native CLI** | Need custom native modules, brownfield apps |
| **Expo with Dev Client** | Best of both - Expo DX with native modules |
---
## Project Setup
### Expo (Recommended)
```bash
npx create-expo-app@latest my-app
cd my-app
npx expo start
```
### React Native CLI
```bash
npx @react-native-community/cli init MyApp
cd MyApp
npx react-native run-ios # or run-android
```
---
## Core Components
### Basic Structure
```tsx
import { View, Text, StyleSheet, ScrollView, SafeAreaView } from "react-native";
export default function App() {
return (
<SafeAreaView style={styles.container}>
<ScrollView contentContainerStyle={styles.content}>
<Text style={styles.title}>Hello World</Text>
</ScrollView>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
},
content: {
padding: 16,
},
title: {
fontSize: 24,
fontWeight: "bold",
},
});
```
### Common Components
```tsx
import {
View,
Text,
Image,
TextInput,
TouchableOpacity,
Pressable,
FlatList,
ActivityIndicator,
Modal,
Switch,
} from 'react-native';
// Touchable with feedback
<Pressable
onPress={handlePress}
style={({ pressed }) => [
styles.button,
pressed && styles.buttonPressed,
]}
>
<Text>Press Me</Text>
</Pressable>
// Text Input
<TextInput
value={text}
onChangeText={setText}
placeholder="Enter text"
style={styles.input}
autoCapitalize="none"
keyboardType="email-address"
returnKeyType="done"
onSubmitEditing={handleSubmit}
/>
// Image
<Image
source={{ uri: 'https://example.com/image.jpg' }}
style={{ width: 100, height: 100 }}
resizeMode="cover"
/>
```
---
## Navigation
### React Navigation Setup
```bash
npm install @react-navigation/native @react-navigation/native-stack
npx expo install react-native-screens react-native-safe-area-context
```
### Stack Navigation
```tsx
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
type RootStackParamList = {
Home: undefined;
Details: { itemId: string };
};
const Stack = createNativeStackNavigator<RootStackParamList>();
export default function App() {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="Home">
<Stack.Screen
name="Home"
component={HomeScreen}
options={{ title: "My App" }}
/>
<Stack.Screen
name="Details"
component={DetailsScreen}
options={({ route }) => ({ title: route.params.itemId })}
/>
</Stack.Navigator>
</NavigationContainer>
);
}
// Navigate
navigation.navigate("Details", { itemId: "123" });
// Go back
navigation.goBack();
```
### Tab Navigation
```tsx
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { Ionicons } from "@expo/vector-icons";
const Tab = createBottomTabNavigator();
function TabNavigator() {
return (
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
const iconName =
route.name === "Home"
? focused
? "home"
: "home-outline"
: focused
? "settings"
: "settings-outline";
return <Ionicons name={iconName} size={size} color={color} />;
},
})}
>
<Tab.Screen name="Home" component={HomeScreen} />
<Tab.Screen name="Settings" component={SettingsScreen} />
</Tab.Navigator>
);
}
```
---
## State Management
### Zustand (Recommended)
```tsx
import { create } from "zustand";
import { persist, createJSONStorage } from "zustand/middleware";
import AsyncStorage from "@react-native-async-storage/async-storage";
interface AuthStore {
user: User | null;
token: string | null;
login: (user: User, token: string) => void;
logout: () => void;
}
export const useAuthStore = create<AuthStore>()(
persist(
(set) => ({
user: null,
token: null,
login: (user, token) => set({ user, token }),
logout: () => set({ user: null, token: null }),
}),
{
name: "auth-storage",
storage: createJSONStorage(() => AsyncStorage),
},
),
);
```
### React Query
```tsx
import {
QueryClient,
QueryClientProvider,
useQuery,
} from "@tanstack/react-query";
const queryClient = new QueryClient();
// Wrap app
<QueryClientProvider client={queryClient}>
<App />
</QueryClientProvider>;
// Use in component
function ItemList() {
const { data, isLoading, error, refetch } = useQuery({
queryKey: ["items"],
queryFn: fetchItems,
});
if (isLoading) return <ActivityIndicator />;
if (error) return <Text>Error: {error.message}</Text>;
return (
<FlatList
data={data}
renderItem={({ item }) => <ItemRow item={item} />}
keyExtractor={(item) => item.id}
onRefresh={refetch}
refreshing={isLoading}
/>
);
}
```
---
## Styling
### StyleSheet
```tsx
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#ffffff",
},
row: {
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
padding: 16,
borderBottomWidth: StyleSheet.hairlineWidth,
borderBottomColor: "#ccc",
},
text: {
fontSize: 16,
color: "#333",
},
shadow: {
shadowColor: "#000",
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.1,
shadowRadius: 4,
elevation: 3, // Android
},
});
```
### NativeWind (Tailwind for RN)
```bash
npm install nativewind tailwindcss
```
```tsx
import { Text, View } from "react-native";
export function Card() {
return (
<View className="bg-white rounded-lg p-4 shadow-md">
<Text className="text-lg font-bold text-gray-900">Card Title</Text>
<Text className="text-gray-600 mt-2">Card content goes here</Text>
</View>
);
}
```
---
## Native Features
### Camera (Expo)
```tsx
import { Camera, CameraType } from "expo-camera";
function CameraScreen() {
const [permission, requestPermission] = Camera.useCameraPermissions();
const cameraRef = useRef<Camera>(null);
const takePicture = async () => {
if (cameraRef.current) {
const photo = await cameraRef.current.takePictureAsync();
console.log(photo.uri);
}
};
if (!permission?.granted) {
return <Button title="Grant Permission" onPress={requestPermission} />;
}
return (
<Camera ref={cameraRef} style={styles.camera} type={CameraType.back}>
<TouchableOpacity onPress={takePicture}>
<Text>Take Photo</Text>
</TouchableOpacity>
</Camera>
);
}
```
### Push Notifications (Expo)
```tsx
import * as Notifications from "expo-notifications";
import { useEffect } from "react";
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: true,
shouldSetBadge: false,
}),
});
async function registerForPushNotifications() {
const { status } = await Notifications.requestPermissionsAsync();
if (status !== "granted") return;
const token = await Notifications.getExpoPushTokenAsync();
return token.data;
}
// Listen for notifications
useEffect(() => {
const subscription = Notifications.addNotificationReceivedListener(
(notification) => {
console.log(notification);
},
);
return () => subscription.remove();
}, []);
```
### Location
```tsx
import * as Location from "expo-location";
async function getLocation() {
const { status } = awRelated 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.