# rerender-derived-state

The rerender-derived-state rule favors derived boolean state over continuously changing values, reducing React re-renders. It fits responsive UI logic.

- 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-derived-state.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-derived-state

## What it does

The rule guides an agent to subscribe to the result a component actually needs, such as a mobile-mode boolean, instead of tracking the window’s changing width. A media-query result can then choose between responsive layouts.

This keeps rendering tied to a state transition rather than every source-value update. Tracking width means a render can happen for each pixel change, so responsive navigation is where the distinction matters most.

## Install

### Claude Code (native platform)

**Manually: put the files in place**
- File: `.claude/rules/rerender-derived-state.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-derived-state.mdc` — Frontmatter: description, globs, alwaysApply

### GitHub Copilot

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

### Windsurf (Devin Desktop)

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

### Cline

**Manually: put the files in place**
- File: `.clinerules/rerender-derived-state.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-derived-state.md

## When to use it
- reduce renders caused by window-width updates
- switch responsive layouts from a media-query result
- replace continuous state with a derived boolean
- review a React component for unnecessary width subscriptions

## Example prompts
- Review this responsive navigation component and replace width tracking with derived boolean state.
- Find renders caused by every window-width change and rewrite the logic around a media-query result.
- Apply the `rerender-derived-state` rule to this React component.

## Similar
- [rerender-derived-state-no-effect](https://affpapa.org/en/nevibecode/rules/rerender-derived-state-no-effect.md) — rule · ★ 7191 repo stars
- [rerender-simple-expression-in-memo](https://affpapa.org/en/nevibecode/rules/rerender-simple-expression-in-memo.md) — rule · ★ 7191 repo stars
- [rerender-no-inline-components](https://affpapa.org/en/nevibecode/rules/rerender-no-inline-components.md) — rule · ★ 1216 repo stars
- [react-state-management](https://affpapa.org/en/nevibecode/skills/react-state-management.md) — skill · 15286 installs
- [zustand-state-management](https://affpapa.org/en/nevibecode/skills/zustand-state-management.md) — skill · 1000 installs
- [legend-state-best-practices](https://affpapa.org/en/nevibecode/skills/legend-state-best-practices.md) — skill · 490 installs

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
