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
/plugin marketplace add fcakyon/claude-codex-settings
/plugin install react-skills@claude-settingsWhat 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-settings2Manually: put the files in place
.claude/rules/list-performance-item-expensive.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/list-performance-item-expensive.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/list-performance-item-expensive.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/list-performance-item-expensive.mdManually: put the files in place
.clinerules/list-performance-item-expensive.mdStep 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