no-use-effect
What it does
This guide steers your agent away from a common React pattern that often causes bugs and extra renders. It is for developers who write or review React components and hooks.
When to use it
- ✓When your agent creates new React components or hooks.
- ✓When it refactors an existing useEffect call.
- ✓When a pull request adds a useEffect that you want reviewed.
Skill link
https://github.com/fastrepl/anarlog/blob/main/.agents/skills/no-use-effect/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Review this React component and remove any useEffect that is not really needed.”
5 new skills a week. 1 minute to read.
How it works
The skill first asks why each effect exists, then replaces it with the simplest pattern that fits. Those include computing values during rendering, using a data library for fetching, handling user actions in event handlers, and a narrow hook for true one-time setup.
Technical content (original SKILL.md)
Original text by the author, straight from 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.
FAQ
When is useEffect still allowed?
Only for a true sync with an outside system that runs once on mount, and only when no simpler pattern fits.
Does it change how my app behaves?
It aims to keep behavior the same, and the guide asks you to run your normal lint, type and test checks afterward.
What is a derived value?
A value computed from other values during rendering, instead of being copied into a separate state variable.
Details
Original description by the author
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
Popularity
- GitHub stars
- 9.7k
- Ranking position
- #12213
- License
- MIT
- Updated
- 11/1/2026
Comments
- …
More skills from this repository
sqlite-schema-design
9.7kHelps your agent design or review database tables that sync across devices with SQLite Sync, following its rules for keys, defaults and schema changes.
anarlog
9.7kHelps your agent search your Anarlog meeting notes, summaries, transcripts, participants and action items, or import a local recording.
Similar skills
angular-developer
280kHelps your agent create Angular code and give project structure advice. Useful for starting new projects, creating code parts, or improving performance and accessibility.
frontend-a11y
280kHelps your agent make web interfaces accessible to everyone. It ensures websites and apps work well with screen readers and keyboard navigation.
frontend-patterns
280kHas your agent apply modern patterns in frontend development. It optimizes performance, manages state, and follows best practices in React and Next.js.