react-native-patterns
하는 일
이 가이드는 React Native와 Expo로 모바일 앱을 정리하고 만드는 방법을 알려 줍니다. 화면 이동, 데이터 관리, 목록 표시, 스타일링, 휴대폰 기능 사용에 대한 모범 사례를 보여 줍니다.
사용하는 경우
- ✓React Native 앱에서 새 화면이나 컴포넌트를 만들 때.
- ✓사용자가 앱 화면 사이를 이동하는 방식을 설정할 때.
- ✓앱에서 정보를 저장하고 가져오는 방법을 정할 때.
스킬 링크
https://github.com/affaan-m/ECC/blob/main/pi/core/skills/react-native-patterns/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“Expo Router를 사용해 React Native 앱 화면 사이의 이동을 어떻게 정리할 수 있을까요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
가이드는 파일로 화면을 구성하는 Expo Router 사용을 제안합니다. 또한 서버, 클라이언트, 폼 데이터를 어떻게 나누는지 설명하고, TanStack Query 같은 라이브러리로 데이터를 효율적으로 가져오는 방법을 알려 줍니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 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
…
자주 묻는 질문
Expo Router란 무엇인가요?
파일 기반으로 React Native 앱의 화면을 정리하는 방식입니다. 폴더 구조가 곧 화면 이동을 정의합니다.
데이터를 왜 나누나요?
데이터를 나누면 코드가 체계적으로 유지되고, 서버 정보가 앱에 불필요하게 중복되는 것을 막을 수 있습니다.
긴 목록을 효율적으로 표시하려면 어떻게 하나요?
가이드는 FlatList 같은 컴포넌트로 ‘가상화(virtualization)’ 기법을 사용하라고 권합니다. 그래야 많은 항목을 보여줄 때도 앱이 느려지지 않습니다.
상세 정보
작성자의 원본 설명
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
인기도
- GitHub 스타
- 280k
- 순위
- #236
- 라이선스
- MIT
- 업데이트
- 2026. 10. 15.
댓글
- …
이 저장소의 다른 스킬
accessibility
280k에이전트가 모든 사람이 쓸 수 있는 인터페이스를 만들도록 돕습니다. 시각 장애나 운동 장애가 있는 사람도 쓸 수 있게 합니다.
agent-architecture-audit
280k에이전트가 모든 것이 올바르게 작동하는지 점검하도록 돕습니다. AI 시스템의 문제를 찾아 고쳐서 기대대로 작동하게 합니다.
agent-eval
280k에이전트가 서로 다른 AI 코딩 도구를 비교하도록 돕습니다. 특정 작업에서 어느 도구가 더 빠르고, 저렴하고, 믿을 만한지 측정합니다.
agent-harness-construction
280k에이전트가 작업을 더 잘 이해하도록 돕습니다. 에이전트가 쓰는 도구와 지시문을 최적화해 성공 가능성을 높입니다.
비슷한 스킬
flutter-animating-apps
101kFlutter 앱에 애니메이션 효과와 전환을 추가하도록 돕습니다. iOS와 Android 앱에서 움직임과 시각 디자인을 만드는 데 유용합니다.
agent-spec-mobile-react-native
81kReact Native로 iPhone과 Android용 모바일 앱을 만들도록 돕습니다. 화면, 내비게이션, 네이티브 모듈을 포함합니다.
orientation
75k에이전트가 세로와 가로 방향 모두에서 사이트가 작동하도록 도와, 방향 잠금과 기기를 돌리라는 메시지를 없애 누구나 콘텐츠에 접근하게 합니다.