Skip to main content
React Native, while powerful for cross-platform mobile development, has several common anti-patterns that can lead to performance issues, maintenance problems, and poor user experience. Here are the most important anti-patterns to avoid when writing React Native code.
Using ScrollView with map for long lists leads to performance issues as it renders all items at once. Use FlatList or SectionList for efficient list rendering with windowing and recycling.
Regular components re-render even when props haven’t changed. Use React.memo for functional components or PureComponent for class components to prevent unnecessary re-renders.
Multiple state updates that affect layout cause performance issues. Batch layout changes and use the Animated API with useNativeDriver when possible.
Creating new function instances on every render can cause unnecessary re-renders in child components. Use useCallback to memoize functions.
Inline styles are recreated on every render and can’t be optimized by React Native. Use StyleSheet.create() to define styles outside the component.
Loading full-size images for small UI elements wastes bandwidth and memory. Request appropriately sized images and use proper resizeMode.
Poor navigation structure leads to maintainability issues. Separate navigation configuration from components and use proper screen options.
Scattering platform-specific code makes components hard to maintain. Use Platform.select() or platform-specific files (e.g., Component.ios.js and Component.android.js).
Prop drilling makes components tightly coupled and hard to maintain. Use Context API for simpler apps or Redux/MobX for complex state management.
Not handling permissions properly leads to crashes and poor user experience. Always check and request permissions before using device features.
Without error boundaries, a single component crash can bring down the entire app. Use error boundaries to gracefully handle component errors.
Ignoring accessibility makes your app unusable for many users. Include accessibility props like accessible, accessibilityLabel, and accessibilityHint.
Heavy operations during app launch increase startup time. Defer non-critical operations and use splash screens with AppLoading component.
Not using Hermes (JavaScript engine optimized for React Native) can result in slower startup times and higher memory usage. Enable Hermes for better performance, especially on Android.