본문으로 건너뛰기
Skillpedia
모바일 앱280k · #236

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가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/affaan-m/ECC/blob/main/pi/core/skills/react-native-patterns/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

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.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬