Community코딩 & 개발github.com

react-native-모범-사례

React Native 애플리케이션의 FPS, TTI, 번들 크기, 메모리 누수, 리렌더링 및 애니메이션을 최적화하기 위한 성능 가이드라인을 제공합니다. Hermes 최적화, JS 스레드 차단, 브릿지 오버헤드, FlashList, 네이티브 모듈 또는 버벅거림 및 프레임 드랍 디버깅과 관련된 작업에 적용됩니다.

react-native-모범-사례란 무엇인가요?

이 스킬은 React Native 애플리케이션의 성능 최적화를 위한 포괄적인 가이드라인을 제공합니다. JavaScript/React 레이어, 네이티브(iOS/Android) 레이어, 그리고 번들링 전반에 걸친 최적화 전략을 다루며, Callstack의 "Ultimate Guide to React Native Optimization"을 기반으로 합니다. 이 가이드는 FPS 및 리렌더링, 번들 크기, TTI, 네이티브 성능, 메모리 관리, 애니메이션 등 핵심 성능 영역을 우선순위별로 분류하여 개발자가 가장 영향력 큰 문제부터 체계적으로 해결할 수 있도록 돕습니다. 주요 지원 플랫폼은 iOS와 Android이며, Hermes 엔진 최적화, Turbo Modules, FlashList, Reanimated, Jotai/Zustand 등 React Native 생태계의 최신 도구와 패턴을 활용한 구체적인 코드 예제와 측정 방법을 제공합니다. 개발자는 '측정 → 최적화 → 재측정 → 검증'의 반복 워크플로우를 통해 성능 문제를 진단하고 개선할 수 있으며, 각 최적화 항목은 상세한 참조 문서와 실제 CLI 명령어로 연결되어 실무에서 바로 적용 가능합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/callstackincubator/agent-skills/tree/main/skills/react-native-best-practices

Installed? Explore more 코딩 & 개발 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

React Native 모범 사례

개요

React Native 애플리케이션을 위한 성능 최적화 가이드입니다. JavaScript/React, 네이티브(iOS/Android), 번들링 최적화를 다룹니다. Callstack의 "Ultimate Guide to React Native Optimization"을 기반으로 합니다.

적용 시기

다음과 같은 상황에서 이 가이드라인을 참조하세요:

  • 느리거나 버벅거리는 UI 또는 애니메이션 디버깅
  • 메모리 누수(JS 또는 네이티브) 조사
  • 앱 시작 시간(TTI) 최적화
  • 번들 또는 앱 크기 감소
  • 네이티브 모듈(Turbo Modules) 작성
  • React Native 성능 프로파일링
  • 성능 관점에서 React Native 코드 검토

보안 참고 사항

  • 이 문서의 셸 명령어는 로컬 개발자 작업으로 간주하세요. 실행 전에 검토하고, 버전이 고정된 도구를 선호하며, 원격 스크립트를 셸에 직접 파이프하는 것을 피하세요.
  • 서드파티 라이브러리와 플러그인은 일반적인 공급망 관리가 필요한 의존성으로 취급하세요: 버전 고정, 출처 확인, 표준 검토 프로세스를 통한 업데이트.
  • 원격 청크 로딩은 자사 아티팩트 전용으로만 처리하세요. 앱에 번들된 청크나 서명된 CI 릴리스 매니페스트를 선호하며, 호스팅된 청크는 신뢰할 수 있는 HTTPS 출처에서 제공되고 현재 앱 릴리스에 고정되어야 합니다.

우선순위 순서 가이드라인

우선순위카테고리영향도접두사
1FPS 및 리렌더링CRITICALjs-*
2번들 크기CRITICALbundle-*
3TTI 최적화HIGHnative-*, bundle-*
4네이티브 성능HIGHnative-*
5메모리 관리MEDIUM-HIGHjs-*, native-*
6애니메이션MEDIUMjs-*

영향도 레이블은 트라이지 힌트입니다: CRITICAL을 먼저, 그 다음 HIGH, 증거가 해당 방향을 가리킬 때 MEDIUM을 처리하세요.

빠른 참조

최적화 워크플로우

모든 성능 문제에 대해 다음 사이클을 따르세요: 측정 → 최적화 → 재측정 → 검증

  1. 측정: 변경 전 기준 메트릭을 캡처합니다. 런타임 문제의 경우, 가능할 때 커밋 타임라인, 리렌더링 횟수, 느린 컴포넌트, 가장 무거운 커밋 분석, 시작/TTI를 선호합니다. 컴포넌트 트리 깊이나 개수는 선택적 맥락일 뿐 대체재가 아닙니다. 측정된 렌더링이나 FPS 문제 없이 메모이제이션, 원자 상태 또는 컴파일러 변경을 추천하지 마세요.
  2. 최적화: 관련 참조에서 대상 수정 사항을 적용합니다.
  3. 재측정: 동일한 측정을 실행하여 업데이트된 메트릭을 얻습니다.
  4. 검증: 개선 확인 (예: FPS 45→60, TTI 3.2초→1.8초, 번들 2.1MB→1.6MB).

메트릭이 개선되지 않은 경우 변경 사항을 되돌리고 다음 제안된 수정을 시도하세요.

검토 가드레일

  • API별 수정을 제안하기 전에 라이브러리 버전을 확인하세요. 예: FlashList v2는 estimatedItemSize를 더 이상 사용하지 않으므로 누락된 것으로 표시하지 마세요.
  • 동작이 명백히 잘못되었거나 프로파일링이 해당 값과 관련된 불필요한 작업을 보여주지 않는 한 useMemo 또는 useCallback 의존성 변경을 제안하지 마세요.
  • 추측성으로 클로저 스테일을 보고하지 마세요. 스테일 읽기 경로, 재현 또는 프로파일러 증거를 먼저 제시하세요.
  • 플로우를 프로파일링할 때 대상 상호작용 자체를 측정하세요. 컴포넌트 트리 깊이나 컴포넌트 개수를 주요 성능 증거로 취급하지 마세요.

중요: FPS 및 리렌더링

먼저 프로파일링:

agent-device react-devtools status
agent-device react-devtools wait --connected
agent-device react-devtools profile start
agent-device react-devtools profile stop
agent-device react-devtools profile slow --limit 5
agent-device react-devtools profile rerenders --limit 5
agent-device react-devtools profile timeline --limit 20

profile start와 profile stop 사이에 일반 agent-device 명령어로 대상 상호작용을 구동하세요.

agent-device를 사용할 수 없을 때 수동 대체: Metro (j) 또는 Dev Menu에서 React Native DevTools를 열고, Profiler 탭을 사용하여 동일한 상호작용을 기록하세요.

릴리스 빌드 React 컴포넌트 프로파일링의 경우, 먼저 @callstack/inspector를 연결하여 React DevTools가 릴리스 앱에 연결되도록 한 다음 위의 agent-device react-devtools 흐름을 실행하세요.

일반적인 수정 사항:

  • 긴 목록의 경우 ScrollView를 FlatList/FlashList/Legend List로 교체
  • 프로파일링 후 계단식 리렌더링이 확인되면 React Compiler를 사용하여 자동 메모이제이션 적용
  • 프로파일링 후 광범위한 스토어/컨텍스트 업데이트가 확인되면 원자 상태(Jotai/Zustand)를 사용하여 리렌더링 감소
  • 값비싼 계산에 useDeferredValue 사용

중요: 번들 크기

번들 분석:

npx react-native bundle \
  --entry-file index.js \
  --bundle-output output.js \
  --platform ios \
  --sourcemap-output output.js.map \
  --dev false --minify true

npx source-map-explorer output.js --no-border-checks

최적화 후 개선 확인:

# 변경 전 기준 크기 기록
ls -lh output.js  # 예: 변경 전: 2.1 MB

# 수정 적용 후 재번들링 및 비교
npx react-native bundle --entry-file index.js --bundle-output output.js \
  --platform ios --dev false --minify true
ls -lh output.js  # 예: 변경 후: 1.6 MB  (24% 감소)

일반적인 수정 사항:

  • 배럴 임포트 피하기 (소스에서 직접 임포트)
  • Hermes API 및 메서드 적용 범위 확인 후 불필요한 Intl 폴리필 제거
  • 트리 쉐이킹 평가 (Expo SDK 52+ 실험적 미사용 import/export 제거, 또는 이미 구성된 경우 Re.Pack)
  • Android 네이티브 코드 축소를 위해 R8 활성화

높음: TTI 최적화

TTI 측정:

  • react-native-performance 사용하여 마커 설정
  • 콜드 스타트만 측정 (웜/핫/프리워밍 제외)

일반적인 수정 사항:

  • React Native 0.78 이하의 경우 Android JS 번들 압축을 비활성화하여 Hermes mmap 활성화
  • 네이티브 내비게이션 사용 (react-native-screens)
  • 자주 사용되는 값비싼 화면을 탐색하기 전에 사전 로드

높음: 네이티브 성능

네이티브 프로파일링:

  • iOS: Xcode Instruments → Time Profiler
  • Android: Android Studio → CPU Profiler

일반적인 수정 사항:

  • 무거운 네이티브 작업에 백그라운드 스레드 사용
  • 동기식 Turbo Module 메서드보다 비동기식 선호
  • 크로스 플랫폼 성능이 중요한 코드에 C++ 사용

참조

전체 문서 및 코드 예제는 references/에 있습니다:

JavaScript/React (js-*)

파일영향도설명
js-lists-flatlist-flashlist.mdCRITICALScrollView를 가상화된 목록으로 교체
js-profile-react.mdMEDIUMagent-device react-devtools 프로파일링
js-measure-fps.mdHIGHFPS 모니터링 및 측정
js-memory-leaks.mdMEDIUMJS 메모리 누수 탐지
js-atomic-state.mdHIGHJotai/Zustand 패턴
js-concurrent-react.mdHIGHuseDeferredValue, useTransition
js-react-compiler.mdHIGH자동 메모이제이션
js-animations-reanimated.mdMEDIUMReanimated worklets
js-bottomsheet.mdHIGHBottom sheet 최적화
js-uncontrolled-components.mdHIGHTextInput 최적화

네이티브 (native-*)

파일영향도설명
native-turbo-modules.mdHIGH빠른 네이티브 모듈 구축
native-sdks-over-polyfills.mdHIGH네이티브 vs JS 라이브러리
native-measure-tti.mdHIGHTTI 측정 설정
native-threading-model.mdHIGHTurbo Module 스레드
native-profiling.mdMEDIUMXcode/Android Studio 프로파일링
native-platform-setup.mdMEDIUMiOS/Android 도구 가이드
native-view-flattening.mdMEDIUM뷰 계층 구조 디버깅
native-memory-patterns.mdMEDIUMC++/Swift/Kotlin 메모리
native-memory-leaks.mdMEDIUM네이티브 메모리 누수 탐지
native-android-16kb-alignment.mdCRITICALGoogle Play용 서드파티 라이브러리 정렬

번들링 (bundle-*)

파일영향도설명
bundle-barrel-exports.mdCRITICAL배럴 임포트 피하기
bundle-analyze-js.mdCRITICALJS 번들 시각화
bundle-tree-shaking.mdHIGH데드 코드 제거
bundle-analyze-app.mdHIGH앱 크기 분석
bundle-r8-android.mdHIGHAndroid 코드 축소
bundle-hermes-mmap.mdHIGH번들 압축 비활성화
bundle-native-assets.mdHIGH에셋 카탈로그 설정
bundle-library-size.mdMEDIUM의존성 평가
bundle-code-splitting.mdMEDIUM원격 청크 로딩 보호 장치

문제 → 스킬 매핑

문제시작 항목
앱이 느리거나 버벅거림js-measure-fps.md → js-profile-react.md
너무 많은 리렌더링js-profile-react.md → js-react-compiler.md
느린 시작 (TTI)native-measure-tti.md → bundle-analyze-js.md
큰 앱 크기bundle-analyze-app.md → bundle-r8-android.md
메모리 증가js-memory-leaks.md 또는 native-memory-leaks.md
애니메이션 프레임 드랍js-animations-reanimated.md
Bottom sheet 버벅거림/리렌더링js-bottomsheet.md → js-animations-reanimated.md
목록 스크롤 버벅거림js-lists-flatlist-flashlist.md
TextInput 지연js-uncontrolled-components.md
네이티브 모듈 느림native-turbo-modules.md → native-threading-model.md
네이티브 라이브러리 정렬 문제native-android-16kb-alignment.md

기여

Callstack의 "The Ultimate Guide to React Native Optimization"을 기반으로 합니다.

Individual skills in this repo

This repo contains 15 individual skills — each has its own dedicated page.

agent-device

Automates interactions for Apple-platform apps (iOS, tvOS, macOS) and Android devices. Use when navigating apps, taking snapshots/screenshots, tapping, typing, scrolling, or extracting UI info across mobile, TV, and desktop targets.

assess-react-native-migration

Assesses whether and how an existing mobile product should migrate to React Native. Use when auditing one or more product repositories for migration readiness, including products whose iOS, Android, and other clients live in separate directories or repositories; choosing brownfield, greenfield, or a checkpoint-based path; defining a representative trial; or preparing a baseline and ROI decision before implementation. When product scope or material evidence is unavailable, grills the stakeholder with exactly one question per turn instead of sending a questionnaire.

callstackincubator/github

GitHub patterns using gh CLI for pull requests, stacked PRs, code review, branching strategies, and repository automation. Use when working with GitHub PRs, merging strategies, or repository management tasks.

callstackincubator/validate-skills

Validates skills in this repo against agentskills.io spec and Claude Code best practices. Use via /validate-skills command.

create-react-native-library

Scaffolds React Native libraries with create-react-native-library for standalone libraries or local native modules and views. Use when creating or working on React Native libraries or adding native functionality in an existing app.

dogfood

Systematically explore and test a mobile app on iOS/Android with agent-device to find bugs, UX issues, and other problems. Use when asked to "dogfood", "QA", "exploratory test", "find issues", "bug hunt", or "test this app" on mobile. Produces a structured report with reproducible evidence: screenshots, optional repro videos, and detailed steps for every issue.

github-actions

GitHub Actions workflow patterns for React Native iOS simulator and Android emulator cloud builds with downloadable artifacts. Use when setting up CI build pipelines or downloading GitHub Actions artifacts via gh CLI and GitHub API.

react-native-brownfield-migration

Implements an accepted incremental brownfield migration from native iOS or Android to React Native or Expo using @callstack/react-native-brownfield. Use after the brownfield path has been selected, when setting up the integration, packaging XCFramework or AAR artifacts, or adding React Native surfaces to native hosts.

react-native-testing

Write tests using React Native Testing Library (RNTL) v13 and v14 (`@testing-library/react-native`). Use when writing, reviewing, or fixing React Native component tests. Covers: render, screen, queries (getBy/getAllBy/queryBy/findBy), Jest matchers, userEvent, fireEvent, waitFor, and async patterns. Supports v13 (React 18, sync render) and v14 (React 19+, async render). Triggers on: test files for React Native components, RNTL imports, mentions of "testing library", "write tests", "component tests", or "RNTL".

react-native-tv-best-practices

Reviews React Native TV apps for focus/D-pad navigation, 10-foot UI layout, TV playback/DRM integration, low-memory TV performance, and TV accessibility. Use when building, debugging, or reviewing react-native-tvos, Expo TV, Amazon Vega/Kepler, or React Native web TV targets where the issue depends on remote input, TV focus, TV packaging, TV hardware, or TV playback constraints.

react-navigation

Provides React Navigation UI patterns for stacks, tabs, drawers etc. Use when building navigation UIs with React Navigation, configuring headers, bottom sheets or handling safe areas and insets.

upgrading-react-native

Upgrades React Native apps to newer versions by applying rn-diff-purge template diffs, updating package.json dependencies, migrating native iOS and Android configuration, resolving CocoaPods and Gradle changes, and handling breaking API updates. Use when upgrading React Native, bumping RN version, updating from RN 0.x to 0.y, or migrating Expo SDK alongside a React Native upgrade.

validate-skills

Validates skills in this repo against agentskills.io spec and Claude Code best practices. Use via /validate-skills command.

vercel-react-native-skills

React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.

writing-user-docs

House style for user-facing documentation — voice, scope, structure, and what to leave out. Use this skill whenever writing, editing, or reviewing anything a user reads to learn how to use a tool — help center articles, getting-started guides, tutorials, feature docs, README usage sections, in-app help, release notes, or FAQ entries. Trigger it even when the request is phrased plainly — "document this feature", "write docs for X", "explain this to users", "write a README for this library", "turn these notes into a guide" — and even when no style guidelines are mentioned. Also use it to review existing docs for tone, bloat, or leaked implementation detail. Do not use it for internal engineering docs, architecture write-ups, RFCs, or code comments.

관련 스킬