Rules
rn-no-raw-text
rn-no-raw-text
Severity: error
Rule ID:Good:
Rule ID:
react-doctor/rn-no-raw-textRequires text to be wrapped in <Text> components. Raw text outside <Text> crashes on React Native.Why it crashes:
React Native doesn’t support raw text nodes like web React. All text must be in <Text> components.Bad:This rule is automatically disabled in files with the
'use dom' directive for React Native’s DOM components.rn-no-deprecated-modules
rn-no-deprecated-modules
Severity: error
Rule ID:Good:
Rule ID:
react-doctor/rn-no-deprecated-modulesDetects removed React Native modules and suggests community alternatives.Deprecated modules:AsyncStorage→@react-native-async-storage/async-storagePicker→@react-native-picker/pickerDatePickerIOS→@react-native-community/datetimepickerSafeAreaView→react-native-safe-area-contextWebView→react-native-webviewNetInfo→@react-native-community/netinfoClipboard→@react-native-clipboard/clipboard
rn-no-legacy-expo-packages
rn-no-legacy-expo-packages
Severity: warn
Rule ID:Good:
Rule ID:
react-doctor/rn-no-legacy-expo-packagesDetects deprecated Expo packages and suggests modern alternatives.Deprecated packages:expo-av→expo-audioandexpo-videoexpo-permissions→ Module-specific permission APIs@expo/vector-icons→expo-imagewith SF Symbols
rn-no-dimensions-get
rn-no-dimensions-get
Severity: warn
Rule ID:Good:
Rule ID:
react-doctor/rn-no-dimensions-getPrevents using Dimensions.get() which doesn’t update on screen rotation. Use useWindowDimensions() for reactive layouts.Why it’s bad:Dimensions.get()returns static values- Doesn’t update on device rotation
- Requires manual event listeners
addEventListenerwas removed in RN 0.72
rn-no-inline-flatlist-renderitem
rn-no-inline-flatlist-renderitem
Severity: warn
Rule ID:Good:Applies to:
Rule ID:
react-doctor/rn-no-inline-flatlist-renderitemPrevents inline renderItem functions on list components. Inline functions create new references every render, breaking list optimization.Why it’s bad:- New function reference every render
- Prevents PureComponent optimization
- List items re-render unnecessarily
- Poor scroll performance
FlatList, SectionList, VirtualizedList, FlashListrn-no-legacy-shadow-styles
rn-no-legacy-shadow-styles
Severity: warn
Rule ID:Good:
Rule ID:
react-doctor/rn-no-legacy-shadow-stylesSuggests using boxShadow instead of legacy shadow properties for the new React Native architecture.Legacy properties:shadowColorshadowOffsetshadowOpacityshadowRadiuselevation(Android)
boxShadow is cross-platform and works on both iOS and Android with the new architecture.rn-prefer-reanimated
rn-prefer-reanimated
Severity: warn
Rule ID:Good:
Rule ID:
react-doctor/rn-prefer-reanimatedSuggests using react-native-reanimated instead of built-in Animated API for performant animations.Why Reanimated is better:- Runs on UI thread (60fps even with blocked JS thread)
- Better gesture handling
- More powerful API
- Smoother animations
rn-no-single-element-style-array
rn-no-single-element-style-array
Severity: warn
Rule ID:Good:
Rule ID:
react-doctor/rn-no-single-element-style-arrayPrevents single-element style arrays which create unnecessary array allocations.Bad:React Native Best Practices
Performance
- Use
FlatListfor long lists, notScrollViewwith.map() - Implement
keyExtractorandgetItemLayoutfor lists - Use
React.memo()for list items - Avoid inline functions in
renderItem - Use
removeClippedSubviewsfor very long lists
Layout
- Use Flexbox (default in RN)
- Avoid absolute positioning when possible
- Use
useWindowDimensions()for responsive layouts - Test on different screen sizes
Images
Navigation
Platform-Specific Code
Testing on Device
Related Rules
- Performance Rules - General performance patterns
- Architecture Rules - Component structure