no-use-effect
하는 일
이 가이드는 버그와 불필요한 렌더링을 자주 일으키는 흔한 React 패턴에서 에이전트를 멀어지게 합니다. React 컴포넌트와 훅을 쓰거나 검토하는 개발자를 위한 가이드입니다.
사용하는 경우
- ✓에이전트가 새 React 컴포넌트나 훅을 만들 때.
- ✓기존 useEffect 호출을 리팩터링할 때.
- ✓풀 리퀘스트가 useEffect를 추가해서 검토하고 싶은 경우.
스킬 링크
https://github.com/fastrepl/anarlog/blob/main/.agents/skills/no-use-effect/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“이 React 컴포넌트를 검토하고, 실제로 필요하지 않은 useEffect를 제거해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
스킬은 먼저 각 effect가 왜 있는지 묻고, 맞는 가장 단순한 패턴으로 바꿉니다. 렌더링 중에 값을 계산하기, 데이터 가져오기에 데이터 라이브러리 쓰기, 사용자 동작은 이벤트 핸들러에서 처리하기, 진짜 일회성 설정에는 좁은 훅을 쓰기가 포함됩니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
No useEffect
Never call useEffect directly unless the work is a true mount-only sync with an external system and no simpler pattern fits. Prefer a render-time computation, a query or mutation hook, an event handler, or a remount boundary instead.
Workflow
- Classify why the effect exists.
- Replace it with the narrowest pattern below.
- Verify with the project's normal lint, typecheck, and tests.
Replacement Patterns
1. Derive state, do not sync it
Replace useEffect(() => setX(derive(y)), [y]) with inline computation or the project's existing memoization conventions.
const filteredProducts = products.filter((product) => product.inStock);
Smell test: state only mirrors props or other state.
2. Use query or mutation libraries for async work
Replace fetch-in-effect code with the app's data layer.
const productQuery = useQuery({
queryKey: ["product", productId],
queryFn: () => fetchProduct(productId),
});
Smell test: the effect fetches, awaits, retries, cancels, or writes async results into local state.
3. Use event handlers for user actions
Do the work where the action happens instead of setting a flag and reacting later.
const handleLike = () => {
postLike();
};
Smell test: state exists only to trigger an effect, then gets reset.
4. Use useMountEffect for mount-only external sync
Use this only for work that is naturally "set up on mount, clean up on unmount": DOM integration, subscriptions, third-party widgets, and stable singleton bindings.
If the project already has a useMountEffect, use it. If not, add a small wrapper:
import { useEffect } from "react";
export function useMountEffect(effect: () => void | (() => void)) {
useEffect(effect, []);
}
Prefer changing component structure so the component only mounts once preconditions are satisfied.
Smell test: the effect is a one-time setup or teardown for something outside React.
5. Use key to reset component state
If a component should behave like a fresh instance when an ID or entity changes, remount it from the parent.
return <VideoPlayer key={videoId} videoId={videoId} />;
Smell test: the effect exists only to reset local state when props change.
Review Standard
Treat new direct useEffect usage as a bug by default. Ask which of the five patterns applies. Accept direct useEffect only with explicit justification that the code is a mount-only external sync and that useMountEffect is the intended escape hatch.
Structure React Code This Way
Order component logic like this:
- Hooks that read external state or data.
- Local state.
- Derived values computed during render.
- Event handlers.
- Early returns.
- Render output.
Do not introduce mirrored state just to make an effect possible.
자주 묻는 질문
useEffect는 언제 허용되나요?
마운트 시 한 번 실행되는 외부 시스템과의 진짜 동기화에만, 더 단순한 패턴이 맞지 않을 때만 허용됩니다.
앱 동작이 바뀌나요?
동작을 그대로 유지하는 것을 목표로 하며, 가이드는 이후에 일반 린트, 타입, 테스트 점검을 실행하라고 요청합니다.
파생 값이란 무엇인가요?
다른 값들로부터 렌더링 중에 계산되는 값으로, 별도의 상태 변수에 복사하지 않은 값입니다.
상세 정보
작성자의 원본 설명
Avoid direct React `useEffect` usage when writing or reviewing React components and hooks. Use this skill when creating new React code, refactoring existing `useEffect` calls, reviewing PRs that introduce `useEffect`, or when an agent reaches for `useEffect` as a default. Replace effects with derived state, query or mutation libraries, event handlers, `useMountEffect` for mount-only external sync, or `key`-based remounts.
repo: fastrepl/anarlog
인기도
- GitHub 스타
- 9.7k
- 순위
- #12213
- 라이선스
- MIT
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
sqlite-schema-design
9.7k에이전트가 SQLite Sync로 기기 간에 동기화되는 테이블을 키와 스키마 변경 규칙에 맞게 설계하도록 돕습니다.
anarlog
9.7k에이전트가 Anarlog 회의 노트, 요약, 녹취록, 참석자, 실행 항목을 검색하거나 로컬 녹음 파일을 가져오도록 돕습니다.
비슷한 스킬
angular-developer
280k에이전트가 Angular 코드를 만들고 프로젝트 구조를 조언하도록 돕습니다. 새 프로젝트 시작, 코드 부분 생성, 성능과 접근성 개선에 유용합니다.
frontend-a11y
280k모든 사람이 웹 인터페이스를 쓸 수 있도록 에이전트를 돕습니다. 웹사이트와 앱이 화면 읽기 프로그램과 키보드 탐색에서 잘 작동하도록 합니다.
frontend-patterns
280k프론트엔드 개발의 현대적인 패턴을 적용하도록 에이전트를 돕습니다. React와 Next.js에서 성능을 최적화하고, 상태를 관리하며, 모범 사례를 따릅니다.