react-doctor/rn-list-data-mapped
Wrap the projection in `useMemo(() => items.map(...), [items])` so the list's `data` prop has a stable reference across parent renders
- Category: React Native
- Severity: warn
- Source:
oxlint-plugin-react-doctor - Framework: react-native
- Enabled when: framework=react-native and capabilities=react-native
Validation prompt
Use this to decide whether a fired diagnostic is real or a false positive.
Confirm the data prop on FlatList, FlashList, LegendList, SectionList, or VirtualizedList is an inline .map(...) or .filter(...) call — a fresh array per parent render busts referential equality and forces the list to re-key every row. False positive when the parent essentially never re-renders, but the useMemo fix is free.
Fix prompt
Use this once validation confirms the diagnostic is real.
Hoist the projection: const rows = useMemo(() => items.map(toRow), [items]) (or move the transform up to wherever items is fetched/derived), then pass data={rows}. Virtualization windows stop resetting and keyExtractor matching stays cheap across renders. See https://reactnative.dev/docs/optimizing-flatlist-configuration
Related rules
More React Native rules from the rules reference:
react-doctor/rn-list-missing-estimated-item-size: Add estimatedItemSize so FlashList/LegendList sizes its initial container pool correctly: <FlashList data={items} estimatedItemSize={64} />react-doctor/rn-list-recyclable-without-types: Add `getItemType={item => item.kind}` so FlashList keeps separate recycle pools per item type — heterogeneous rows shouldn't share recycled cellsreact-doctor/rn-no-deep-imports: Import from the "react-native" package root, not the deprecated "react-native/Libraries/..." subpath: import { Alert } from "react-native"react-doctor/rn-no-deprecated-modules: Import from the community package instead — deprecated modules were removed from the react-native corereact-doctor/rn-no-dimensions-get: Use `const { width, height } = useWindowDimensions()` — it updates reactively on rotation and resize