# rerender-dependencies

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.

- rule · `type=rule` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline · ★ 1064 repo stars
- Author: jarrodwatts
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/jarrodwatts/claude-code-config/tree/HEAD/skills/vercel-react-best-practices/rules/rerender-dependencies.md
- Updated: 2026-01-21
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/rules/rerender-dependencies

## What it 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.

## Install

### Claude Code (native platform)

**Manually: put the files in place**
- File: `.claude/rules/rerender-dependencies.md` — The paths frontmatter field limits the files

### Codex

**AGENTS.md**
- Codex reads AGENTS.md: paste the rule text there

### Cursor

**Manually: put the files in place**
- File: `.cursor/rules/rerender-dependencies.mdc` — Frontmatter: description, globs, alwaysApply

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/instructions/rerender-dependencies.instructions.md` — The applyTo field sets which files it applies to

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/rules/rerender-dependencies.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/rerender-dependencies.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/jarrodwatts/claude-code-config/tree/HEAD/skills/vercel-react-best-practices/rules/rerender-dependencies.md

## When to use it
- 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 `useEffect` body
- replace a pixel-width dependency with a boolean flag
- defend `user.id` in a dependency array during code review

## Example prompts
- Check the `useEffect` deps in `Profile.tsx` and keep only primitives there
- Move the `isMobile` calculation out of the effect and depend on the boolean
- Find effects that rerun whenever the window width changes

## Similar
- [rerender-derived-state-no-effect](https://affpapa.org/en/nevibecode/rules/rerender-derived-state-no-effect.md) — rule · ★ 7191 repo stars
- [rerender-move-effect-to-event](https://affpapa.org/en/nevibecode/rules/rerender-move-effect-to-event.md) — rule · ★ 7191 repo stars
- [no-use-effect](https://affpapa.org/en/nevibecode/skills/no-use-effect.md) — skill · 1100 installs
- [react-useeffect](https://affpapa.org/en/nevibecode/skills/react-useeffect.md) — skill · 127 installs
- [react-core](https://affpapa.org/en/nevibecode/skills/react-core.md) — skill · 220 installs
- [rerender-no-inline-components](https://affpapa.org/en/nevibecode/rules/rerender-no-inline-components.md) — rule · ★ 1216 repo stars

From the same set: [jarrodwatts/claude-code-config](https://affpapa.org/en/nevibecode/by/jarrodwatts/claude-code-config.md) — 20 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
