Skip to main content
rule CX Codex

list-performance-item-expensive — Claude Code rule: what it does

The list-performance-item-expensive rule bans heavy list rows: data queries, extra hooks and React Context reads inside renderItem.

MIT ★ 1,216 updated 2026-10-24

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add fcakyon/claude-codex-settings
/plugin install react-skills@claude-settings
Open on GitHub

What list-performance-item-expensive does

The rule keeps list row components down to plain rendering functions that take primitive props and return JSX. Data fetching, derived computations and multiple React Context reads inside a list item are flagged — that logic belongs in the parent component, which fetches data once and passes ready values down.

For values shared across rows and updated often, such as whether an item sits in a cart, the rule points to Zustand selectors instead of Context: a Context read re-renders every row whenever any tracked value changes, while a selector re-renders only the row tied to the changed value. It also calls out checking membership with Set.has() rather than Array.includes().

The reasoning ties to virtualization: a virtualized list re-renders many rows on every scroll frame, so any expensive operation inside a row shows up as visible jank.

What it helps with

  • strip data fetching out of list row components
  • swap React Context for Zustand selectors in list items
  • spot expensive computations hiding inside renderItem
  • move data loading up to the parent list component
  • cut re-renders that cause jank in a virtualized list

Example prompts for the agent

  • Check my list row components against the list-performance-item-expensive rule
  • Rewrite ProductRow to only accept primitive props
  • Replace the useContext call in this list item with a Zustand selector

How to install list-performance-item-expensive

1Plugin marketplace

/plugin marketplace add fcakyon/claude-codex-settings
/plugin install react-skills@claude-settings

2Manually: put the files in place

.claude/rules/list-performance-item-expensive.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 list-performance-item-expensive

How do I install list-performance-item-expensive in Claude Code?

Run /plugin marketplace add fcakyon/claude-codex-settings, then /plugin install react-skills@claude-settings. The rule lands in the project as .claude/rules/list-performance-item-expensive.md.

What does list-performance-item-expensive do?

It keeps list row components as plain rendering functions, flagging data queries, heavy computations, and extra hooks or Context reads inside each item.

Why does the rule push Zustand selectors over Context in lists?

A Context read re-renders every row when any tracked value changes, while a Zustand selector only re-renders the row tied to that specific value — a difference that matters once a virtualized list scrolls through many rows.

Source text

list-performance-item-expensive.md · MIT
---
title: Keep List Items Lightweight
impact: HIGH
impactDescription: reduces render time for visible items during scroll
tags: lists, performance, virtualization, hooks
---

## Keep List Items Lightweight

List items should be as inexpensive as possible to render. Minimize hooks, avoid
queries, and limit React Context access. Virtualized lists render many items
during scroll—expensive items cause jank.

**Incorrect (heavy list item):**

```tsx
function ProductRow({ id }: { id: string }) {
  // Bad: query inside list item
  const { data: product } = useQuery(['product', id], () => fetchProduct(id))
  // Bad: multiple context accesses
  const theme = useContext(ThemeContext)
  const user = useContext(UserContext)
  const cart = useContext(CartContext)
  // Bad: expensive computation
  const recommendations = useMemo(
    () => computeRecommendations(product),
    [product]
  )

  return <View>{/* ... */}</View>
}
```

**Correct (lightweight list item):**

```tsx
function ProductRow({ name, price, imageUrl }: Props) {
  // Good: receives only primitives, minimal hooks
  return (
    <View>
      <Image source={{ uri: imageUrl }} />
      <Text>{name}</Text>
      <Text>{price}</Text>
    </View>
  )
}
```

**Move data fetching to parent:**

```tsx
// Parent fetches all data once
function ProductList() {
  const { data: products } = useQuery(['products'], fetchProducts)

  return (
    <LegendList
      data={products}
      renderItem={({ item }) => (
        <ProductRow name={item.name} price={item.price} imageUrl={item.image} />
      )}
    />
  )
}
```

**For shared values, use Zustand selectors instead of Context:**

```tsx
// Incorrect: Context causes re-render when any cart value changes
function ProductRow({ id, name }: Props) {
  const { items } = useContext(CartContext)
  const inCart = items.includes(id)
  // ...
}

// Correct: Zustand selector only re-renders when this specific value changes
function ProductRow({ id, name }: Props) {
  // use Set.has (created once at the root) instead of Array.includes()
  const inCart = useCartStore((s) => s.items.has(id))
  // ...
}
```

**Guidelines for list items:**

- No queries or data fetching
- No expensive computations (move to parent or memoize at parent level)
- Prefer Zustand selectors over React Context
- Minimize useState/useEffect hooks
- Pass pre-computed values as props

The goal: list items should be simple rendering functions that take props and
return JSX.

© fcakyon · MIT · fcakyon/claude-codex-settings

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set113

The whole set →
setup Skill for Claude Code configures real integration testing and user QA journeys across project codebases. It triggers when asked to set up QA or generate end-to-end testing flows. CX Codex +1 ★ 1,216repo stars list-performance-inline-objects list-performance-inline-objects — a rule that prevents creating objects inside renderItem for props. Inline objects create new references on every render and break memoization. CX Codex +1 ★ 1,216repo stars setup setup configures Tavily MCP server credentials inside Claude Code and saves them to the plugin configuration. CX Codex +1 ★ 1,216repo stars bundle-analyzable-paths The bundle-analyzable-paths rule recommends making import and file paths statically analyzable. That keeps bundlers from treating a broad set of files as reachable. CX Codex +1 ★ 1,216repo stars ui-image-gallery ui-image-gallery directs AI assistants to build image galleries using @nandorojo/galeria instead of custom modal popups. CX Codex +1 ★ 1,216repo stars rendering-resource-hints The rendering-resource-hints rule tells the agent when to call React DOM's resource-hint functions inside React components. It targets server components, letting the browser start fetching assets before the client even has the HTML. CX Codex +1 ★ 1,216repo stars animation-gesture-detector-press animation-gesture-detector-press is a React Native rule that keeps press animations on the UI thread, for buttons that scale or fade while pressed. CX Codex +1 ★ 1,216repo stars commit-staged commit-staged automates commit creation: checks staged diffs, runs /simplify on code edits, and writes conventional commits using session rationale. CX Codex +1 ★ 1,216repo stars

Project sponsors

Companies that keep this analytics open