Skip to main content
rule CX Codex

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

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-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 in memo() but re-render on every render
  • Find all renderItem calls passing inline objects as props
  • Hoist styles from renderItem into module-level constants

How to install list-performance-inline-objects

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-inline-objects.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-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

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set113

The whole set →
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 list-performance-item-memo 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. 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 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 list-performance-item-expensive The list-performance-item-expensive rule bans heavy list rows: data queries, extra hooks and React Context reads inside renderItem. 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

Project sponsors

Companies that keep this analytics open