rerender-dependencies — Claude Code rule for useEffect deps
rerender-dependencies — a Claude rule that keeps useEffect dependency arrays on primitives like user.id rather than whole objects, so an effect stops firing on every field change.
no license ★ 1,064 updated 2026-01-21
.claude/rules/rerender-dependencies.mdWhat rerender-dependencies does
The rule file ships two tsx snippets, one wrong and one right. The first depends on user.id instead of the user object, so the effect reruns only when the id moves. The second lifts a derived flag out of the effect: compute isMobile = width < 768 first, then list that boolean. Raw width as a dependency fires at 767, 766, 765 and so on.
This is a style rule, and the author tags it low impact. Fewer effect reruns help a little. Components that don't use React hooks have nothing to gain from it.
Drop the markdown at .claude/rules/rerender-dependencies.md inside your project.
What it helps with
- stop an effect from rerunning when an unrelated user field changes
- swap an object dependency for a primitive id
- move derived state out of a
useEffectbody - replace a pixel-width dependency with a boolean flag
- defend
user.idin a dependency array during code review
Example prompts for the agent
- Check the
useEffectdeps inProfile.tsxand keep only primitives there - Move the
isMobilecalculation out of the effect and depend on the boolean - Find effects that rerun whenever the window width changes
How to install rerender-dependencies
Manually: put the files in place
.claude/rules/rerender-dependencies.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/rerender-dependencies.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/rerender-dependencies.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/rerender-dependencies.mdManually: put the files in place
.clinerules/rerender-dependencies.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about rerender-dependencies
How do I install rerender-dependencies in Claude Code?
Place the rule file in your project at .claude/rules/rerender-dependencies.md.
What does rerender-dependencies do?
It pushes the agent toward primitive dependencies in useEffect and toward computing derived state before the effect runs.
Why depend on user.id instead of user?
Any edit to the object gives it a new identity, while the id changes only when the id itself changes. The primitive keeps the effect quiet.