Pulled ALL skills from 15 source repositories: - anthropics/skills: 16 (docs, design, MCP, testing) - obra/superpowers: 14 (TDD, debugging, agents, planning) - coreyhaines31/marketingskills: 25 (marketing, CRO, SEO, growth) - better-auth/skills: 5 (auth patterns) - vercel-labs/agent-skills: 5 (React, design, Vercel) - antfu/skills: 16 (Vue, Vite, Vitest, pnpm, Turborepo) - Plus 13 individual skills from various repos Mosaic Stack is not limited to coding — the Orchestrator and subagents serve coding, business, design, marketing, writing, logistics, analysis, and more. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
68 lines
1.7 KiB
Markdown
68 lines
1.7 KiB
Markdown
---
|
|
title: Use a List Virtualizer for Any List
|
|
impact: HIGH
|
|
impactDescription: reduced memory, faster mounts
|
|
tags: lists, performance, virtualization, scrollview
|
|
---
|
|
|
|
## Use a List Virtualizer for Any List
|
|
|
|
Use a list virtualizer like LegendList or FlashList instead of ScrollView with
|
|
mapped children—even for short lists. Virtualizers only render visible items,
|
|
reducing memory usage and mount time. ScrollView renders all children upfront,
|
|
which gets expensive quickly.
|
|
|
|
**Incorrect (ScrollView renders all items at once):**
|
|
|
|
```tsx
|
|
function Feed({ items }: { items: Item[] }) {
|
|
return (
|
|
<ScrollView>
|
|
{items.map((item) => (
|
|
<ItemCard key={item.id} item={item} />
|
|
))}
|
|
</ScrollView>
|
|
)
|
|
}
|
|
// 50 items = 50 components mounted, even if only 10 visible
|
|
```
|
|
|
|
**Correct (virtualizer renders only visible items):**
|
|
|
|
```tsx
|
|
import { LegendList } from '@legendapp/list'
|
|
|
|
function Feed({ items }: { items: Item[] }) {
|
|
return (
|
|
<LegendList
|
|
data={items}
|
|
// if you aren't using React Compiler, wrap these with useCallback
|
|
renderItem={({ item }) => <ItemCard item={item} />}
|
|
keyExtractor={(item) => item.id}
|
|
estimatedItemSize={80}
|
|
/>
|
|
)
|
|
}
|
|
// Only ~10-15 visible items mounted at a time
|
|
```
|
|
|
|
**Alternative (FlashList):**
|
|
|
|
```tsx
|
|
import { FlashList } from '@shopify/flash-list'
|
|
|
|
function Feed({ items }: { items: Item[] }) {
|
|
return (
|
|
<FlashList
|
|
data={items}
|
|
// if you aren't using React Compiler, wrap these with useCallback
|
|
renderItem={({ item }) => <ItemCard item={item} />}
|
|
keyExtractor={(item) => item.id}
|
|
/>
|
|
)
|
|
}
|
|
```
|
|
|
|
Benefits apply to any screen with scrollable content—profiles, settings, feeds,
|
|
search results. Default to virtualization.
|