list-performance-inline-objects — Claude Code rule
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.
MIT ★ 1,216 updated 2026-10-24
/plugin marketplace add fcakyon/claude-codex-settings
/plugin install react-skills@claude-settingsWhat list-performance-inline-objects does
The rule catches code where renderItem passes inline objects: styles, new user={{ id, name }} constructs, or other values assembled on the fly. Each object gets a new reference, memo() sees a changed prop and re-renders the row even when the data is unchanged.
Instead, the agent passes primitives (item.id, item.name) or the entire item. Styles are hoisted to module-level constants or computed inside the memoized component. This lets React skip unnecessary renders.
Marked HIGH impact: re-rendering all list rows on scroll slows the UI. If React Compiler is enabled, it optimizes automatically, but without it the rule is critical for long lists.
What it helps with
- all list rows re-rendering on scroll due to inline objects
- broken memoization for components wrapped in
memo() - slow scroll in long React Native
FlatList
Example prompts for the agent
- Check
UserList: rows are wrapped inmemo()but re-render on every render - Find all
renderItemcalls passing inline objects as props - Hoist styles from
renderIteminto module-level constants
How to install list-performance-inline-objects
1Plugin marketplace
/plugin marketplace add fcakyon/claude-codex-settings/plugin install react-skills@claude-settings2Manually: put the files in place
.claude/rules/list-performance-inline-objects.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-inline-objects.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/list-performance-inline-objects.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/list-performance-inline-objects.mdManually: put the files in place
.clinerules/list-performance-inline-objects.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-inline-objects
How to install list-performance-inline-objects in Claude Code?
Run /plugin marketplace add fcakyon/claude-codex-settings, then /plugin install react-skills@claude-settings. The file will appear in .claude/rules/list-performance-inline-objects.md.
What does list-performance-inline-objects do?
Prevents creating objects inside renderItem to avoid breaking memoization. The agent passes primitives or hoists styles into constants.
When can you skip this rule?
If React Compiler is enabled, it memoizes automatically. Short lists without scrolling also do not need it.
Source text
list-performance-inline-objects.md · MIT
---
title: Avoid Inline Objects in renderItem
impact: HIGH
impactDescription: prevents unnecessary re-renders of memoized list items
tags: lists, performance, flatlist, virtualization, memo
---
## Avoid Inline Objects in renderItem
Don't create new objects inside `renderItem` to pass as props. Inline objects
create new references on every render, breaking memoization. Pass primitive
values directly from `item` instead.
**Incorrect (inline object breaks memoization):**
```tsx
function UserList({ users }: { users: User[] }) {
return (
<LegendList
data={users}
renderItem={({ item }) => (
<UserRow
// Bad: new object on every render
user={{ id: item.id, name: item.name, avatar: item.avatar }}
/>
)}
/>
)
}
```
**Incorrect (inline style object):**
```tsx
renderItem={({ item }) => (
<UserRow
name={item.name}
// Bad: new style object on every render
style={{ backgroundColor: item.isActive ? 'green' : 'gray' }}
/>
)}
```
**Correct (pass item directly or primitives):**
```tsx
function UserList({ users }: { users: User[] }) {
return (
<LegendList
data={users}
renderItem={({ item }) => (
// Good: pass the item directly
<UserRow user={item} />
)}
/>
)
}
```
**Correct (pass primitives, derive inside child):**
```tsx
renderItem={({ item }) => (
<UserRow
id={item.id}
name={item.name}
isActive={item.isActive}
/>
)}
const UserRow = memo(function UserRow({ id, name, isActive }: Props) {
// Good: derive style inside memoized component
const backgroundColor = isActive ? 'green' : 'gray'
return <View style={[styles.row, { backgroundColor }]}>{/* ... */}</View>
})
```
**Correct (hoist static styles in module scope):**
```tsx
const activeStyle = { backgroundColor: 'green' }
const inactiveStyle = { backgroundColor: 'gray' }
renderItem={({ item }) => (
<UserRow
name={item.name}
// Good: stable references
style={item.isActive ? activeStyle : inactiveStyle}
/>
)}
```
Passing primitives or stable references allows `memo()` to skip re-renders when
the actual values haven't changed.
**Note:** If you have the React Compiler enabled, it handles memoization
automatically and these manual optimizations become less critical.
© fcakyon · MIT · fcakyon/claude-codex-settings