rn-legend-list
Installation
SKILL.md
Legend List — Best Practices & Performance Guide
@legendapp/list v2.0+ | React Native 0.72+ | Pure TypeScript — no native dependencies
Critical Rules
- Always provide
keyExtractorwith stable, unique IDs. Without it, Legend List cannot track items across data changes, causing unnecessary re-renders and layout bugs. - Enable
recycleItems={true}for any list beyond a handful of items. This is the single biggest performance win — it reuses view containers instead of creating/destroying them on scroll. - Use
useRecyclingStateinstead ofuseStateinside recycled items. RegularuseStatecarries state from the previous item when a container is reused, causing ghost data bugs. - Use
useRecyclingEffectto reset side effects (animations, subscriptions, timers) when an item container is recycled to a different data item. - Provide accurate size estimates via
estimatedItemSizeorgetEstimatedItemSize. Bad estimates cause layout jumping and scroll position inaccuracies. - Use
getFixedItemSizefor any item whose height is known at render time. This skips measurement entirely — the fastest path. - Use
getItemTypewhenrecycleItemsis enabled and your list has multiple visually different item types. This ensures containers are only recycled to items with the same structure. - Memoize
renderItemwithuseCallbackand item components withReact.memo. Inline arrow functions create new references every render, triggering unnecessary work. - Enable
maintainVisibleContentPosition(default in v2) for any list where items are added/removed above the viewport — especially chat and bidirectional lists. - Never mutate the
dataarray. Always produce a new array reference with immutable operations ([...prev, newItem],.map(),.filter()).
Code Review & Audit Action
Related skills