Skip to main content
rule CX Codex

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

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/rendering-hoist-jsx.md
Open on GitHub

What 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.md

The paths frontmatter field limits the files

Step 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

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set130

The whole set →
rendering-conditional-render The rendering-conditional-render rule prevents accidental rendering of zeros and NaN in JSX. It enforces explicit ternary operators instead of && checks, so falsy values stay out of the DOM. CX Codex +1 ★ 7,191repo stars server-serialization server-serialization is a Claude Code rule for limiting data passed across React Server/Client boundaries. It applies when client components receive props from server components. CX Codex +1 ★ 7,191repo stars rerender-simple-expression-in-memo The rerender-simple-expression-in-memo rule advises against using useMemo for simple expressions that return a boolean, number, or string. It applies when reviewing React component calculations. CX Codex +1 ★ 7,191repo stars js-hoist-regexp js-hoist-regexp — a Claude rule that keeps RegExp construction out of the render path: define the pattern at module scope or wrap it in useMemo(). CX Codex +1 ★ 7,191repo stars rerender-transitions The rerender-transitions rule marks frequent, non-urgent state changes as transitions. It fits React code where updates such as scroll tracking should keep the interface responsive. CX Codex +1 ★ 7,191repo stars advanced-use-latest advanced-use-latest — a Claude rule file on reaching fresh callback values inside a React effect and keeping the dependency array down to state. CX Codex +1 ★ 7,191repo stars async-api-routes async-api-routes prevents sequential waterfall requests in API routes and Server Actions. It instructs the assistant to launch independent promises immediately rather than chaining awaits. CX Codex +1 ★ 7,191repo stars js-early-exit The js-early-exit rule recommends returning as soon as a function’s result is clear. It fits checks where continuing after the first error serves no purpose. CX Codex +1 ★ 7,191repo stars

Project sponsors

Companies that keep this analytics open