본문으로 건너뛰기
Skillpedia
웹사이트 및 UI (프런트엔드)29k · #9365

react-best-practices

하는 일

이 스킬은 성능이 좋은 React 코드를 작성하고 검토하기 위한 지침을 제공합니다. 로딩 지연을 피하고, 번들을 작게 유지하며, 불필요한 다시 렌더링을 줄이는 내용을 다룹니다.

사용하는 경우

  • ✓새 React 컴포넌트나 데이터 가져오기 코드를 작성할 때.
  • ✓속도나 크기 문제가 있는지 React 코드를 검토할 때.
  • ✓React 앱이 느리게 로드되거나 너무 자주 다시 렌더링될 때.

스킬 링크

https://github.com/mastra-ai/mastra/blob/main/.claude/skills/react-best-practices/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

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

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

AI에게 요청하는 예시

“내 React 대시보드가 로드가 느립니다. 컴포넌트를 검토하고 가장 큰 성능 개선점을 알려 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 우선순위가 정해진 규칙 집합에 맞춰 코드를 검토합니다. 워터폴 제거와 번들 크기처럼 영향이 가장 큰 항목부터 시작해, 영향이 큰 순서대로 변경을 제안합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

React Best Practices

Overview

Routing and priority guide for React performance and quality, containing 27 rules across 9 categories. Rule files hold the detailed explanations, examples, review smells, and impact metrics.

When to Apply

Reference these guidelines when:

  • Writing new React components
  • Implementing data fetching
  • Reviewing code for performance issues
  • Refactoring existing React code
  • Optimizing bundle size or load times

Priority-Ordered Guidelines

Rules are prioritized by impact:

Priority Category Impact
1 Eliminating Waterfalls CRITICAL
2 Bundle Size Optimization CRITICAL
3 Client-Side Data Fetching MEDIUM-HIGH
4 Re-render Optimization MEDIUM
5 Rendering Performance MEDIUM
6 JavaScript Performance LOW-MEDIUM
7 Component Structure MEDIUM-HIGH (maintainability)
8 Testing MEDIUM-HIGH (correctness)
9 Type Safety HIGH

Quick Reference

Critical Patterns (Apply First)

Eliminate Waterfalls:

  • Use Promise.all() for independent async operations (async-parallel)

Reduce Bundle Size:

  • Avoid barrel file imports, import directly from source (bundle-barrel-imports)
  • Defer non-critical third-party libraries (bundle-defer-third-party)

Medium-Impact Patterns

Client-Side Data Fetching:

  • Use Tanstack Query for automatic request deduplication (client-request-dedupe)
  • Dependent query params are the value or undefined, never | null or a fake fallback; narrow at the caller so hooks stay strict, or guard with skipToken when the hook must accept an optional param (client-request-dedupe)

Re-render Optimization:

  • Use lazy state initialization for expensive values (rerender-lazy-state-init)
  • Apply startTransition for non-urgent updates (rerender-transitions)
  • Keep UI handlers plain; use Effect Events only for effect-fired logic (rerender-useeffect-function-calls)
  • Never reset state with useEffect; lift the discriminant and remount the branch (rerender-no-useeffect-state-reset)
  • Never add useMemo or useCallback; leave memoization decisions to developers with profiler evidence (rerender-no-usememo-usecallback)
  • Never call setState during render or inside useEffect; derive during render or move state ownership to an intermediate component (rerender-no-setstate-in-render-or-effect)

Component Structure:

  • One domain component/hook per file, one responsibility each — split bloated components (structure-single-responsibility)
  • Keep component, hook, function, and utility APIs narrow: split oversized props, arguments, and return objects into focused units composed at the component level; wrapping the same values in one object is not a fix (structure-narrow-apis)
  • Use PascalCase components for JSX-returning helpers; keep lowercase helpers for non-JSX values (structure-component-naming)
  • Derive props/params instead of accepting a value computable from another arg (structure-derive-dont-duplicate)
  • Extract complex derived logic into named locals plus predicates or pure helpers with early returns: oversized conditions, nested ternaries, ternaries that compute instead of picking (multi-line branches, or an as cast re-asserting what the condition tested), fallback chains, and let-based render prep are code smells, in render prep and in hook options, request builders, config maps, and reducers alike (structure-complex-derived-logic)
  • Pick the view with early if guards but keep the layout wrapper in one place — branch a body component, don't ternary or duplicate the shell (structure-early-return-render-branches)
  • For a fixed set of items, write one component per item with explicit props that owns its data and loading — don't map a config-object array onto a component shape (structure-composition-over-config)
  • When a domain component fetches data, render through a pure layout component that positions slots, and branch the slot contents between skeletons and resolved sub-domain components (structure-data-fetching-layout)

Testing:

  • BDD tests that d
자주 묻는 질문

무엇을 먼저 고치나요?

워터폴 제거와 번들 크기 축소처럼 영향이 가장 큰 영역을 먼저 다룹니다.

테스트도 다루나요?

네. 성능과 함께 테스트와 타입 안전성에 관한 지침도 포함합니다.

한 프레임워크만을 위한 것인가요?

아닙니다. 일반적인 React 코드를 대상으로 하며, 예시와 규칙은 일반적인 React 앱에 적용됩니다.

상세 정보

작성자의 원본 설명

React performance optimization guidelines from Mastra Engineering. This skill should be used when writing, reviewing, or refactoring React code to ensure optimal performance patterns. Triggers on tasks involving React components, data fetching, bundle optimization, or performance improvements.

repo: mastra-ai/mastra

인기도

GitHub 스타
29k
순위
#9365
라이선스
—
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬