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
/plugin marketplace add fcakyon/claude-codex-settings
/plugin install react-skills@claude-settingsWhat 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
onPressout 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
UserRowand tell me whymemo()still re-renders it, then switch the props to primitives - Rework
renderItemin thisFlatListso the row takesidandnameand handles the press itself - Run this list screen through the
list-performance-item-memorule 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-settings2Manually: put the files in place
.claude/rules/list-performance-item-memo.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-memo.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/list-performance-item-memo.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/list-performance-item-memo.mdManually: put the files in place
.clinerules/list-performance-item-memo.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-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