react-native-patterns
Helps your agent build and edit mobile apps using React Native and Expo. It handles navigation, data, styling, and secure storage.
What it does
This guide teaches how to organize and build mobile apps using React Native and Expo. It shows best practices for navigation, data management, displaying lists, styling, and using phone features.
When to use it
- ✓When creating new screens or components in a React Native app.
- ✓When setting up how the user navigates between app screens.
- ✓When deciding how to store and fetch information in the app.
Example of what to ask your AI
“How can I organize navigation between my React Native app screens using Expo Router?”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
The guide suggests using Expo Router to organize screens by files. It also explains how to separate data types (from server, client, forms) and how to fetch data efficiently using libraries like TanStack Query.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add affaan-m/ECC --skill react-native-patternsOr download just the file:
curl -L https://raw.githubusercontent.com/affaan-m/ECC/main/pi/core/skills/react-native-patterns/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
React Native / Expo Patterns
Practical patterns for building production React Native apps with Expo. Covers navigation, state, data fetching, lists, styling, and native APIs. Pairs with the rules/react-native/ ruleset: rules say what to enforce, this skill shows how.
Libraries named below (NativeWind, Zustand/Jotai, TanStack Query) are common, well-established options shown for illustration — the patterns matter more than the specific package, and any equivalent works. Zod is used for validation to stay consistent with ECC's existing typescript/ rules.
These patterns assume the managed Expo workflow (Expo Router, EAS, expo-* modules) on the New Architecture (the default in recent Expo SDKs, mandatory from SDK 55+). They do NOT assume the browser DOM — React Native has no <div>, no URL bar, and no web data-fetching defaults.
When to Activate
Use this skill when:
- Building or editing React Native / Expo screens, components, or navigation
- Setting up routing with Expo Router (file-based
app/directory) - Deciding where state belongs (server cache vs client store vs route params vs form)
- Wiring data fetching with TanStack Query and validating responses with Zod
- Rendering long or heavy lists
- Choosing or applying a styling approach (NativeWind or StyleSheet)
- Accessing native device APIs (camera, location, notifications) or secure storage
- Reviewing RN code for mobile-specific issues
Do NOT use the web/React-DOM patterns here — URL-as-state, <div>, and SWR-for-browser do not apply to React Native.
Core Concepts
Project structure (Expo Router)
File-based routing under app/. Keep route files thin: they read and validate params, then delegate to a screen component that lives in components/ or features/.
app/
_layout.tsx # root stack
(tabs)/
_layout.tsx # tab navigator
index.tsx # Home
user/[id].tsx # dynamic route
components/
features/
user/UserProfile.tsx
Navigation: validate route params
Deep links and dynamic routes deliver untrusted strings. Validate them with Zod before use.
// app/user/[id].tsx
import { useLocalSearchParams, router } from 'expo-router'
import { z } from 'zod'
import { UserProfile } from '@/features/user/UserProfile'
const Params = z.object({ id: z.string().uuid() })
export default function UserRoute() {
const parsed = Params.safeParse(useLocalSearchParams())
if (!parsed.success) {
router.replace('/not-found')
return null
}
return <UserProfile userId={parsed.data.id} />
}
State: keep concerns separate
Do not duplicate server data into a client store. Each concern has its own home.
| Concern | Common choices |
|---|---|
| Server state (remote data) | a server-cache library (TanStack Query, SWR) |
| Client/UI state | a lightweight store (Zustand, Jotai) or Context |
| Route/navigation state | Expo Router params |
| Form state | a form library (e.g. React Hook Form) + schema validation |
| Secrets / tokens | expo-secure-store |
| Non-secret persistence | AsyncStorage / MMKV |
Prefer local useState until state genuinely needs sharing.
Data fetching: a cache library + Zod
Use a server-cache library (TanStack Query, SWR) instead of fetch-in-useEffect. Validate at the boundary and infer types from the schema. Handle loading, error, and empty states explicitly. (Example uses TanStack Query.)
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
import { z } from 'zod'
const User = z.object({ id: z.string(), email: z.string().email() })
type User = z.infer<typeof User>
export function useUser(id: string) {
return useQuery({
queryKey: ['user', id],
queryFn: async (): Promise<User> => User.parse(await api.getUser(id)),
})
}
export function useUpdateEmail(id: string) {
const qc = useQueryClient()
return useMutation({
mutationFn: (email: string) => api.updateEmail(id, email),
onSuccess: () => qc.invalidateQueries({ queryKey: ['user', id] }),
})
}
Lists: virtualize, never map a big array in a ScrollView
import { FlatList } from 'react-native'
<FlatList
data={items}
keyExtractor={(item) => item.id}
renderItem={renderItem} // memoized
initialNumToRender={10}
windowSize={5}
/>
Use FlashList (Shopify) for large or heterogeneous lists.
Styling: pick one system
…
FAQ
What is Expo Router?
It's a file-based way to organize your React Native app's screens, where the folder structure defines the navigation.
Why separate data types?
Separating data helps keep the code organized and prevents server information from being unnecessarily duplicated in the app.
How to display long lists efficiently?
The guide recommends using techniques like 'virtualization' with components like FlatList so the app doesn't slow down when displaying many items.
Details
Original description by the author
React Native and Expo app patterns — Expo Router navigation, state separation (server/client/route/form), TanStack Query data fetching with Zod, performant lists, NativeWind/StyleSheet styling, native APIs, and secure storage. Use when building or editing React Native / Expo screens, components, navigation, or data layers.
repo: affaan-m/ECC
Popularity
- GitHub stars
- 280k
- Ranking position
- #111
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
accessibility
Helps your agent create interfaces that everyone can use. Ensures websites and apps work well for people with disabilities, like those who are blind or have reduced mobility.
affaan-m/ECC
agent-architecture-audit
Makes your agent check if everything is working correctly. It finds and fixes problems in AI systems, ensuring they perform as expected.
affaan-m/ECC
agent-eval
Helps your agent compare different AI coding tools. It measures which one is faster, cheaper, and more reliable for specific tasks.
affaan-m/ECC
agent-harness-construction
Makes your agent better understand how to perform tasks. It optimizes the tools and instructions the agent uses to increase its chances of success.
affaan-m/ECC
Similar skills
flutter-animating-apps
Lets your agent add animated effects and transitions in Flutter apps. It's useful for creating motion and visual design in iOS and Android apps.
nexu-io/open-design
add-app-clip
Lets your agent add an iOS App Clip to an Expo app. It's useful for creating lightweight app versions opened by links.
sickn33/agentic-awesome-skills
android-dev
Helps develop Android applications. It covers different ways to create apps, native or cross-platform.
sickn33/agentic-awesome-skills