← ClaudeAtlas

no-use-effectlisted

ALWAYS ACTIVE in React and React Native repos. Enforces a strict no-direct-useEffect rule. Never write useEffect directly — use derived state, event handlers, useMemo, useSyncExternalStore, data-fetching libraries, key-based resets, or useMountEffect instead. Triggers on all React component code: writing new components, editing existing ones, reviewing code, fixing bugs, or refactoring. Also triggers when user mentions useEffect, side effects, data fetching, state sync, or component lifecycle. Does not apply to non-React code, and a repo's own AGENTS.md rule wins over this default.
RIJUDEVx/agent-skills · ★ 1 · Code & Development · score 74
Install: claude install-skill RIJUDEVx/agent-skills
# No Direct useEffect Never call `useEffect` directly. For the rare case of syncing with an external system on mount, use `useMountEffect()`. This rule is the default in React and React Native code. A repo's own `AGENTS.md` rule wins when it says otherwise, and it never applies to non-React code. ```tsx export function useMountEffect(effect: () => void | (() => void)) { /* eslint-disable react-hooks/exhaustive-deps, no-restricted-syntax */ useEffect(effect, []); } ``` The only place `useEffect` may appear directly is inside reusable custom hooks (like `useMountEffect` itself, or a `useData` hook when no fetching library is available). Components must never import or call `useEffect`. ## The 6 Rules ### Rule 1: Derive state, do not sync it If you can calculate it from existing state/props, compute it inline. ```tsx // BAD: two render cycles const [filteredProducts, setFilteredProducts] = useState([]); useEffect(() => { setFilteredProducts(products.filter((p) => p.inStock)); }, [products]); // GOOD: one render const filteredProducts = products.filter((p) => p.inStock); ``` For expensive calculations, use `useMemo`: ```tsx const visibleTodos = useMemo( () => getFilteredTodos(todos, filter), [todos, filter] ); ``` **Smell test:** You're about to write `useEffect(() => setX(f(y)), [y])` or state that only mirrors other state/props. ### Rule 2: Use data-fetching libraries Effect-based fetching creates race conditions and reinvents caching. ```tsx // BAD: ra