Skip to main content
rule CX Codex

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

list-performance-item-memo — a rule for React list rows: split the item into primitive props so memo() can compare them shallowly and skip a render when nothing changed.

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-memo does

This one targets the component that draws a single row. Rather than handing the whole item object down as one prop, you spread its strings, numbers and booleans across separate props. Shallow comparison inside memo() then works, and the row sits still while its data stays the same.

The rule file carries TSX snippets. One pair puts a UserRow that takes a user object next to the version taking id, name and email. A second block trims props to the fields the row actually renders. Callbacks get their own section: hoist the handler upward, or pass the item id and keep the press logic inside the child behind useCallback.

An object prop defeats the comparison, because memo() only looks at the reference. A parent that rebuilds that object on every render throws the saving away, even with identical values. Turn the React Compiler on and memo() plus useCallback() become optional, though object references still count.

What it helps with

  • stop a row from re-rendering when its data did not change
  • convert a row component from object props to primitives
  • pull an inline onPress out of the props
  • explain during review why memo() is not skipping renders
  • pass only the fields the row actually draws

Example prompts for the agent

  • Look at UserRow and tell me why memo() still re-renders it, then switch the props to primitives
  • Rework renderItem in this FlatList so the row takes id and name and handles the press itself
  • Run this list screen through the list-performance-item-memo rule and point out where a whole object gets passed

How to install list-performance-item-memo

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-memo.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-memo

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

Add the marketplace with /plugin marketplace add fcakyon/claude-codex-settings, then run /plugin install react-skills@claude-settings. The rule lands as .claude/rules/list-performance-item-memo.md.

What does list-performance-item-memo do?

It pushes the agent to give list row components primitive props, so memo() can compare them shallowly and skip renders when the values match. It also covers what to do with callbacks.

Do I still need memo() and useCallback() with the React Compiler?

No, you can leave both out once the compiler is enabled. Object references in props still behave the same way, so splitting the item into primitives remains useful.

Source text

list-performance-item-memo.md · MIT
---
title: Pass Primitives to List Items for Memoization
impact: HIGH
impactDescription: enables effective memo() comparison
tags: lists, performance, memo, primitives
---

## Pass Primitives to List Items for Memoization

When possible, pass only primitive values (strings, numbers, booleans) as props
to list item components. Primitives enable shallow comparison in `memo()` to
work correctly, skipping re-renders when values haven't changed.

**Incorrect (object prop requires deep comparison):**

```tsx
type User = { id: string; name: string; email: string; avatar: string }

const UserRow = memo(function UserRow({ user }: { user: User }) {
  // memo() compares user by reference, not value
  // If parent creates new user object, this re-renders even if data is same
  return <Text>{user.name}</Text>
})

renderItem={({ item }) => <UserRow user={item} />}
```

This can still be optimized, but it is harder to memoize properly.

**Correct (primitive props enable shallow comparison):**

```tsx
const UserRow = memo(function UserRow({
  id,
  name,
  email,
}: {
  id: string
  name: string
  email: string
}) {
  // memo() compares each primitive directly
  // Re-renders only if id, name, or email actually changed
  return <Text>{name}</Text>
})

renderItem={({ item }) => (
  <UserRow id={item.id} name={item.name} email={item.email} />
)}
```

**Pass only what you need:**

```tsx
// Incorrect: passing entire item when you only need name
<UserRow user={item} />

// Correct: pass only the fields the component uses
<UserRow name={item.name} avatarUrl={item.avatar} />
```

**For callbacks, hoist or use item ID:**

```tsx
// Incorrect: inline function creates new reference
<UserRow name={item.name} onPress={() => handlePress(item.id)} />

// Correct: pass ID, handle in child
<UserRow id={item.id} name={item.name} />

const UserRow = memo(function UserRow({ id, name }: Props) {
  const handlePress = useCallback(() => {
    // use id here
  }, [id])
  return <Pressable onPress={handlePress}><Text>{name}</Text></Pressable>
})
```

Primitive props make memoization predictable and effective.

**Note:** If you have the React Compiler enabled, you do not need to use
`memo()` or `useCallback()`, but the object references still apply.

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

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set113

The whole set →
state-ground-truth state-ground-truth — a rule that stops agents from storing derived visual values in state. Keeps React and Reanimated logic centered on facts. CX Codex +1 ★ 1,216repo stars ui-styling ui-styling enforces modern React Native styling practices: smooth continuous borders, gap spacing, CSS boxShadow syntax, and native gradients. CX Codex +1 ★ 1,216repo stars ui-measure-views ui-measure-views guides agents to measure React Native view dimensions using useLayoutEffect alongside onLayout without triggering unneeded re-renders. CX Codex +1 ★ 1,216repo stars create-issue create-issue is a Claude Code skill for drafting or revising issues about bugs and missing features. It can also refine an issue title or body before publication. CX Codex +1 ★ 1,216repo stars react-state-dispatcher react-state-dispatcher enforces functional dispatch updaters in React setState calls whenever state depends on current values. Prevents stale closures in callbacks. CX Codex +1 ★ 1,216repo stars 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

Project sponsors

Companies that keep this analytics open