# react-compiler-destructure-functions

react-compiler-destructure-functions is a Claude Code rule that enforces extracting hook functions early in render scope. It targets projects running the React Compiler.

- rule · `type=rule` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline · ★ 88 repo stars
- Author: alexj11324
- License: AGPL-3.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/alexj11324/Mikka/tree/HEAD/.claude/skills/react-native-skills/rules/react-compiler-destructure-functions.md
- Updated: 2026-11-17
- Security check: automated, 2026-11-17 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/rules/react-compiler-destructure-functions

## What it does

The rule forbids calling functions by dotting into objects such as `props.onSave()` or `router.push()`. It instructs the agent to pull functions out immediately at the top level of the component or within parameter definitions.

React Compiler creates cache keys using the referenced objects. When code accesses properties via dot notation, the compiler binds to objects that mutate across renders, which invalidates memoization. Destructuring provides stable references that preserve the cache.

This guideline applies exclusively to setups with the React Compiler enabled.

## Install

### Claude Code (native platform)

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

### GitHub Copilot

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

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/rules/react-compiler-destructure-functions.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/react-compiler-destructure-functions.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/alexj11324/Mikka/tree/HEAD/.claude/skills/react-native-skills/rules/react-compiler-destructure-functions.md

## When to use it
- prevent memoization loss under React Compiler
- extract hook methods into stable references early
- eliminate property access calls inside event handlers

## Example prompts
- Check SaveButton.tsx for dot-notation calls on hook objects
- Refactor handlers to destructure functions from props and hooks early

## Similar
- [react-advanced](https://affpapa.org/en/nevibecode/skills/react-advanced.md) — skill · 209 installs
- [react](https://affpapa.org/en/nevibecode/skills/pedro-nauck-react.md) — skill · 483 installs
- [react-doctor](https://affpapa.org/en/nevibecode/skills/react-doctor.md) — skill · 22800 installs
- [react-performance](https://affpapa.org/en/nevibecode/skills/react-performance.md) — skill · 6700 installs
- [react-best-practices](https://affpapa.org/en/nevibecode/skills/mastra-ai-react-best-practices.md) — skill · 2900 installs
- [react-performance-optimizer](https://affpapa.org/en/nevibecode/agents/react-performance-optimizer.md) — subagent · 2081 installs

From the same set: [alexj11324/mikka](https://affpapa.org/en/nevibecode/by/alexj11324/mikka.md) — 47 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
