react-doctor/rn-no-inline-object-in-list-item
Hoist style/object props outside renderItem (StyleSheet.create, useMemo at list scope, or pass primitives) so memo() row components stop bailing
- 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.
Verify a JSX prop inside renderItem, renderSectionHeader, or renderSectionFooter is an inline object literal (style={{...}}, user={{...}}, etc.) — a fresh object reference per row per render. False positive when the row component isn't wrapped in React.memo: there's no shallow compare to break, just GC pressure from extra allocations.
Fix prompt
Use this once validation confirms the diagnostic is real.
Move static styles into const styles = StyleSheet.create({ row: {...} }) and pass style={styles.row}. For per-row dynamic objects, build a stable lookup with useMemo at list scope and pass primitives (id, value) into the memoized row so it composes its own style. See https://reactnative.dev/docs/optimizing-flatlist-configuration
Related rules
More React Native rules from the rules reference:
react-doctor/rn-no-legacy-expo-packages: Migrate to the recommended replacement package — legacy Expo packages are no longer maintainedreact-doctor/rn-no-legacy-shadow-styles: Use `boxShadow` for cross-platform shadows on the new architecture instead of platform-specific shadow propertiesreact-doctor/rn-no-non-native-navigator: Use `@react-navigation/native-stack` (or `native-tabs` in v7+) for platform-native transitions and gesturesreact-doctor/rn-no-panresponder: Replace PanResponder with react-native-gesture-handler's Gesture.Pan(), which runs gesture math on the native UI thread instead of the JS thread.react-doctor/rn-no-raw-text: Wrap text in a `<Text>` component: `<Text>{value}</Text>` — raw strings outside `<Text>` crash on React Native