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

react-useeffect

하는 일

이 스킬은 AI 에이전트가 React의 useEffect를 정말 필요할 때만 쓰도록 가르칩니다. 더 단순하게 바꿀 수 있는 effect가 있는 React 코드를 가진 개발자를 위한 것입니다.

사용하는 경우

  • ✓React 컴포넌트에서 useEffect를 작성하거나 검토할 때.
  • ✓useState와 useEffect로 상태를 동기화하는 방식이 어색하게 느껴질 때.
  • ✓React에서 데이터를 가져오거나 상태를 초기화하며 가장 깔끔한 방법을 원하는 경우.

스킬 링크

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/react-useeffect/SKILL.md

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

사용 방법

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

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

Use this skill to help me: https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/react-useeffect/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 컴포넌트를 검토하고 필요 없는 useEffect 호출을 제거해 주세요.”

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

작동 방식

에이전트는 각 Effect를 Effect가 필요하지 않은 사례 목록과 비교합니다. 파생 값이나 이벤트 응답처럼 해당되는 경우에는 렌더링 중 계산하거나 이벤트 핸들러를 쓰는 등 더 단순한 패턴으로 바꿉니다.

기술 내용 (원본 SKILL.md)

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

You Might Not Need an Effect

Effects are an escape hatch from React. They let you synchronize with external systems. If there is no external system involved, you shouldn't need an Effect.

Quick Reference

Situation DON'T DO
Derived state from props/state useState + useEffect Calculate during render
Expensive calculations useEffect to cache useMemo
Reset state on prop change useEffect with setState key prop
User event responses useEffect watching state Event handler directly
Notify parent of changes useEffect calling onChange Call in event handler
Fetch data useEffect without cleanup useEffect with cleanup OR framework

When You DO Need Effects

  • Synchronizing with external systems (non-React widgets, browser APIs)
  • Subscriptions to external stores (use useSyncExternalStore when possible)
  • Analytics/logging that runs because component displayed
  • Data fetching with proper cleanup (or use framework's built-in mechanism)

When You DON'T Need Effects

  1. Transforming data for rendering - Calculate at top level, re-runs automatically
  2. Handling user events - Use event handlers, you know exactly what happened
  3. Deriving state - Just compute it: const fullName = firstName + ' ' + lastName
  4. Chaining state updates - Calculate all next state in the event handler

Decision Tree

Need to respond to something?
├── User interaction (click, submit, drag)?
│   └── Use EVENT HANDLER
├── Component appeared on screen?
│   └── Use EFFECT (external sync, analytics)
├── Props/state changed and need derived value?
│   └── CALCULATE DURING RENDER
│       └── Expensive? Use useMemo
└── Need to reset state when prop changes?
    └── Use KEY PROP on component

Detailed Guidance

자주 묻는 질문

Effect가 정말 필요한 경우는 언제인가요?

브라우저 API나 React 밖의 구독처럼 외부 시스템과 동기화해야 할 때 필요합니다.

상태를 초기화할 때는 무엇으로 대체하나요?

key prop을 사용하면 prop이 바뀔 때 컴포넌트의 상태를 초기화할 수 있습니다.

데이터 가져오기는 어떻게 하나요?

정리 함수가 있는 Effect를 쓰거나, 프레임워크에 내장된 데이터 메커니즘을 씁니다.

상세 정보

작성자의 원본 설명

React useEffect best practices from official docs. Use when writing/reviewing useEffect, useState for derived values, data fetching, or state synchronization. Teaches when NOT to use Effect and better alternatives.

repo: davila7/claude-code-templates

인기도

GitHub 스타
33k
순위
#8793
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬