rerender-no-inline-components — Claude Code rule
The rerender-no-inline-components rule flags React components declared inside other components, a pattern that causes remounts on parent renders. Use it when state, focus, or scroll position keeps resetting.
MIT ★ 1,216 updated 2026-10-24
/plugin marketplace add fcakyon/claude-codex-settings
/plugin install react-skills@claude-settingsWhat rerender-no-inline-components does
A component declared inside another component gets a new type whenever its parent renders. React then unmounts the old instance and mounts a new one, which can discard state and recreate DOM nodes. Inputs may lose focus, animations can restart, and scroll position may reset.
The rule points toward moving child components to the top level and passing the values they need as props. In its example, Avatar and Stats receive their data from UserProfile. That keeps their component types stable across parent renders.
For Claude Code, the rule is part of react-skills. It concerns React component structure, so projects without React have no use for this check. The listed installation steps target Claude Code; Codex has no install command in the provided commands.
What it helps with
- spot components declared inside another component
- stop inputs from losing focus on parent renders
- preserve child component state between renders
- trace animations or scroll resets to remounts
Example prompts for the agent
- Review
UserProfileand find any components declared inside it; suggest moving them outside. - Find why this React input loses focus whenever its parent renders.
- Check whether a component declared inside its parent is being remounted and losing state.
How to install rerender-no-inline-components
1Plugin marketplace
/plugin marketplace add fcakyon/claude-codex-settings/plugin install react-skills@claude-settings2Manually: put the files in place
.claude/rules/rerender-no-inline-components.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-no-inline-components.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/rerender-no-inline-components.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/rerender-no-inline-components.mdManually: put the files in place
.clinerules/rerender-no-inline-components.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about rerender-no-inline-components
How do I install rerender-no-inline-components in Claude Code?
Run /plugin marketplace add fcakyon/claude-codex-settings, then /plugin install react-skills@claude-settings. The rule file is .claude/rules/rerender-no-inline-components.md.
What does rerender-no-inline-components do?
It flags React components declared inside other components. Their type changes on each parent render, so React remounts them and can discard state or recreate DOM nodes.
Why does an input lose focus when its parent renders?
A component declared inside its parent is one possible cause: React treats it as a new type and remounts it. The rule recommends moving that component to the top level and passing its values as props.
Source text
rerender-no-inline-components.md · MIT
---
title: Don't Define Components Inside Components
impact: HIGH
impactDescription: prevents remount on every render
tags: rerender, components, remount, performance
---
## Don't Define Components Inside Components
**Impact: HIGH (prevents remount on every render)**
Defining a component inside another component creates a new component type on every render. React sees a different component each time and fully remounts it, destroying all state and DOM.
A common reason developers do this is to access parent variables without passing props. Always pass props instead.
**Incorrect (remounts on every render):**
```tsx
function UserProfile({ user, theme }) {
// Defined inside to access `theme` - BAD
const Avatar = () => (
<img
src={user.avatarUrl}
className={theme === 'dark' ? 'avatar-dark' : 'avatar-light'}
/>
)
// Defined inside to access `user` - BAD
const Stats = () => (
<div>
<span>{user.followers} followers</span>
<span>{user.posts} posts</span>
</div>
)
return (
<div>
<Avatar />
<Stats />
</div>
)
}
```
Every time `UserProfile` renders, `Avatar` and `Stats` are new component types. React unmounts the old instances and mounts new ones, losing any internal state, running effects again, and recreating DOM nodes.
**Correct (pass props instead):**
```tsx
function Avatar({ src, theme }: { src: string; theme: string }) {
return (
<img
src={src}
className={theme === 'dark' ? 'avatar-dark' : 'avatar-light'}
/>
)
}
function Stats({ followers, posts }: { followers: number; posts: number }) {
return (
<div>
<span>{followers} followers</span>
<span>{posts} posts</span>
</div>
)
}
function UserProfile({ user, theme }) {
return (
<div>
<Avatar src={user.avatarUrl} theme={theme} />
<Stats followers={user.followers} posts={user.posts} />
</div>
)
}
```
**Symptoms of this bug:**
- Input fields lose focus on every keystroke
- Animations restart unexpectedly
- `useEffect` cleanup/setup runs on every parent render
- Scroll position resets inside the component
© fcakyon · MIT · fcakyon/claude-codex-settings