list-performance-item-types — правило для Claude Code: списки
Правило list-performance-item-types для Claude Code задаёт типы элементов в списках с разной разметкой. Оно подключается при работе с такими списками и настраивает раздельное переиспользование компонентов.
MIT ★ 1 216 обновлён 2026-10-24
/plugin marketplace add fcakyon/claude-codex-settings
/plugin install react-skills@claude-settingsЧто делает list-performance-item-types
Правило предлагает добавлять каждому элементу поле type и передавать тип в getItemType у LegendList. Для заголовков, сообщений и изображений задаются отдельные компоненты; элементы одного типа попадают в общий пул переиспользования, а заголовок не заменяет ячейку изображения.
В примере на TypeScript типы элементов объединены в FeedItem, а switch выбирает компонент по значению type. Для оценки размеров можно настроить getEstimatedItemSize с отдельным значением для каждого типа. Этот подход рассчитан на LegendList и требует поля type в данных списка.
Какие задачи решает
- разделить переиспользование ячеек с разной разметкой
- не допустить замену заголовка ячейкой изображения
- сузить тип элемента в ветках
switchна TypeScript - задать оценку размера отдельно для каждого типа
Примеры запросов агенту
- Настрой список
LegendListтак, чтобы сообщения и изображения использовали разные пулы ячеек. - Перепиши
Feedс типами элементовheader,messageиimage. - Добавь оценку размера элемента для каждого типа в
getEstimatedItemSize.
Как установить list-performance-item-types
1Через маркетплейс плагинов
/plugin marketplace add fcakyon/claude-codex-settings/plugin install react-skills@claude-settings2Вручную: положить файлы
.claude/rules/list-performance-item-types.mdПоле paths во frontmatter ограничивает файлы
AGENTS.md
Codex читает AGENTS.md: вставьте текст правила туда
Вручную: положить файлы
.cursor/rules/list-performance-item-types.mdcВо frontmatter: description, globs, alwaysApply
Вручную: положить файлы
.github/instructions/list-performance-item-types.instructions.mdПоле applyTo задаёт, к каким файлам применять
Вручную: положить файлы
.devin/rules/list-performance-item-types.mdВручную: положить файлы
.clinerules/list-performance-item-types.mdПо шагам, с командами для каждой платформы: AGENTS.md и CLAUDE.md: что это, кто читает и какой выбрать
Вопросы о list-performance-item-types
Как установить list-performance-item-types в Claude Code?
Выполни команды по порядку: /plugin marketplace add fcakyon/claude-codex-settings, затем /plugin install react-skills@claude-settings. Правило также доступно в .claude/rules/list-performance-item-types.md.
Что делает list-performance-item-types?
Правило учит задавать тип каждому элементу неоднородного списка и передавать его в getItemType. LegendList разделяет такие элементы по пулам переиспользования.
Как задавать размеры для разных типов элементов?
Передай функцию в getEstimatedItemSize и возвращай оценку в зависимости от itemType, например отдельно для заголовков, сообщений и изображений.
Исходный текст
list-performance-item-types.md · MIT
---
title: Use Item Types for Heterogeneous Lists
impact: HIGH
impactDescription: efficient recycling, less layout thrashing
tags: list, performance, recycling, heterogeneous, LegendList
---
## Use Item Types for Heterogeneous Lists
When a list has different item layouts (messages, images, headers, etc.), use a
`type` field on each item and provide `getItemType` to the list. This puts items
into separate recycling pools so a message component never gets recycled into an
image component.
**Incorrect (single component with conditionals):**
```tsx
type Item = { id: string; text?: string; imageUrl?: string; isHeader?: boolean }
function ListItem({ item }: { item: Item }) {
if (item.isHeader) {
return <HeaderItem title={item.text} />
}
if (item.imageUrl) {
return <ImageItem url={item.imageUrl} />
}
return <MessageItem text={item.text} />
}
function Feed({ items }: { items: Item[] }) {
return (
<LegendList
data={items}
renderItem={({ item }) => <ListItem item={item} />}
recycleItems
/>
)
}
```
**Correct (typed items with separate components):**
```tsx
type HeaderItem = { id: string; type: 'header'; title: string }
type MessageItem = { id: string; type: 'message'; text: string }
type ImageItem = { id: string; type: 'image'; url: string }
type FeedItem = HeaderItem | MessageItem | ImageItem
function Feed({ items }: { items: FeedItem[] }) {
return (
<LegendList
data={items}
keyExtractor={(item) => item.id}
getItemType={(item) => item.type}
renderItem={({ item }) => {
switch (item.type) {
case 'header':
return <SectionHeader title={item.title} />
case 'message':
return <MessageRow text={item.text} />
case 'image':
return <ImageRow url={item.url} />
}
}}
recycleItems
/>
)
}
```
**Why this matters:**
- **Recycling efficiency**: Items with the same type share a recycling pool
- **No layout thrashing**: A header never recycles into an image cell
- **Type safety**: TypeScript can narrow the item type in each branch
- **Better size estimation**: Use `getEstimatedItemSize` with `itemType` for
accurate estimates per type
```tsx
<LegendList
data={items}
keyExtractor={(item) => item.id}
getItemType={(item) => item.type}
getEstimatedItemSize={(index, item, itemType) => {
switch (itemType) {
case 'header':
return 48
case 'message':
return 72
case 'image':
return 300
default:
return 72
}
}}
renderItem={({ item }) => {
/* ... */
}}
recycleItems
/>
```
Reference:
[LegendList getItemType](https://legendapp.com/open-source/list/api/props/#getitemtype-v2)
© fcakyon · MIT · fcakyon/claude-codex-settings