rendering-hoist-jsx — Claude Code rule: what it does, how to install
rendering-hoist-jsx extracts static JSX elements outside components to prevent element re-creation on every render pass.
MIT ★ 7,191 updated 2026-10-24
.claude/rules/rendering-hoist-jsx.mdWhat rendering-hoist-jsx does
The rule guides the agent to extract unchanging JSX markup into top-level module constants instead of creating nested helper components. Static parts like loading skeletons or headers stay allocated once across re-renders.
This technique helps keep large static SVG nodes from being recreated repeatedly. When a project enables React Compiler, this manual hoist is redundant because the compiler handles static JSX automatically.
What it helps with
- prevent recreating static JSX trees across repeated renders
- move heavy static SVG icons out of component bodies
- replace one-off static placeholder components with module constants
Example prompts for the agent
- Refactor this table view by hoisting static SVG elements
- Optimize our loading skeletons using the rendering-hoist-jsx guideline
- Clean up re-renders in the sidebar by extracting static markup
How to install rendering-hoist-jsx
Manually: put the files in place
.claude/rules/rendering-hoist-jsx.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/rendering-hoist-jsx.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/rendering-hoist-jsx.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/rendering-hoist-jsx.mdManually: put the files in place
.clinerules/rendering-hoist-jsx.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about rendering-hoist-jsx
How to install rendering-hoist-jsx in Claude Code?
Place the rule file at .claude/rules/rendering-hoist-jsx.md in your project.
What does rendering-hoist-jsx do?
It guides the agent to extract static JSX markup outside React components to avoid re-creating elements on every render.
Do I need rendering-hoist-jsx if React Compiler is active?
No. When React Compiler is enabled, it automatically hoists static JSX elements during compilation.
Source text
rendering-hoist-jsx.md · MIT
---
title: Hoist Static JSX Elements
impact: LOW
impactDescription: avoids re-creation
tags: rendering, jsx, static, optimization
---
## Hoist Static JSX Elements
Extract static JSX outside components to avoid re-creation.
**Incorrect (recreates element every render):**
```tsx
function LoadingSkeleton() {
return <div className="animate-pulse h-20 bg-gray-200" />
}
function Container() {
return (
<div>
{loading && <LoadingSkeleton />}
</div>
)
}
```
**Correct (reuses same element):**
```tsx
const loadingSkeleton = (
<div className="animate-pulse h-20 bg-gray-200" />
)
function Container() {
return (
<div>
{loading && loadingSkeleton}
</div>
)
}
```
This is especially helpful for large and static SVG nodes, which can be expensive to recreate on every render.
**Note:** If your project has [React Compiler](https://react.dev/learn/react-compiler) enabled, the compiler automatically hoists static JSX elements and optimizes component re-renders, making manual hoisting unnecessary.
© tech-leads-club · MIT · tech-leads-club/agent-skills