DEV Community

Muhammad Zulqarnain Akram
Muhammad Zulqarnain Akram

Posted on • Originally published at zunain.com

React Native Performance: Building High-Performance Mobile Apps

React Native has transformed how I build mobile applications, enabling true cross-platform development while maintaining near-native performance. Here's my experience and the practices that have made my React Native projects successful.

Why React Native?

Single Codebase, Multiple Platforms

  • Share 80-90% of code between iOS and Android
  • Faster development cycles
  • Consistent user experience across platforms
  • Lower maintenance costs

Performance Optimization Techniques

1. Optimize Re-renders

import React, { memo, useCallback } from 'react';

const ProductCard = memo(({ product, onPress }) => {
  return (
    <TouchableOpacity onPress={() => onPress(product.id)}>
      <Text>{product.name}</Text>
      <Text>${product.price}</Text>
    </TouchableOpacity>
  );
});

export default ProductCard;
Enter fullscreen mode Exit fullscreen mode

2. FlatList Optimization

<FlatList
  data={products}
  renderItem={renderProduct}
  keyExtractor={item => item.id}
  removeClippedSubviews={true}
  maxToRenderPerBatch={10}
  updateCellsBatchingPeriod={50}
  initialNumToRender={10}
  windowSize={10}
  getItemLayout={(data, index) => ({
    length: ITEM_HEIGHT,
    offset: ITEM_HEIGHT * index,
    index,
  })}
/>
Enter fullscreen mode Exit fullscreen mode

3. Image Optimization

import FastImage from 'react-native-fast-image';

<FastImage
  source={{
    uri: imageUrl,
    priority: FastImage.priority.normal,
    cache: FastImage.cacheControl.immutable
  }}
  resizeMode={FastImage.resizeMode.cover}
/>
Enter fullscreen mode Exit fullscreen mode

Architecture Best Practices

State Management with Redux Toolkit

import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';

export const fetchProducts = createAsyncThunk(
  'products/fetch',
  async (category) => {
    const response = await api.getProducts(category);
    return response.data;
  }
);

const productsSlice = createSlice({
  name: 'products',
  initialState: { items: [], loading: false },
  reducers: {},
  extraReducers: (builder) => {
    builder
      .addCase(fetchProducts.pending, (state) => {
        state.loading = true;
      })
      .addCase(fetchProducts.fulfilled, (state, action) => {
        state.items = action.payload;
        state.loading = false;
      });
  },
});
Enter fullscreen mode Exit fullscreen mode

Navigation Structure

import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';

const Stack = createNativeStackNavigator();

function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator screenOptions={{ headerShown: false }}>
        <Stack.Screen name="Home" component={HomeScreen} />
        <Stack.Screen name="Product" component={ProductScreen} />
        <Stack.Screen name="Cart" component={CartScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}
Enter fullscreen mode Exit fullscreen mode

Native Modules Integration

When you need platform-specific functionality:

import { NativeModules, Platform } from 'react-native';

const { BiometricAuth } = NativeModules;

const authenticateUser = async () => {
  if (Platform.OS === 'ios') {
    return await BiometricAuth.authenticateWithFaceID();
  } else {
    return await BiometricAuth.authenticateWithFingerprint();
  }
};
Enter fullscreen mode Exit fullscreen mode

Production Deployment Tips

Performance

  • Enable Hermes engine for faster startup
  • Use ProGuard/R8 for Android code shrinking
  • Optimize bundle size with Metro bundler

Testing

  • Unit tests with Jest
  • E2E tests with Detox
  • Visual regression testing

Monitoring

  • Integrate Sentry for crash reporting
  • Use React Native Performance monitoring
  • Track bundle size metrics

My Experience

Building mobile apps with React Native has allowed me to deliver high-quality applications faster than traditional native development. The key is understanding when to use native modules for performance-critical features while leveraging JavaScript for business logic.

The React Native ecosystem continues to evolve, and with tools like Expo, the developer experience has never been better.

What's your experience with React Native? Share your optimization tips in the comments!

Top comments (0)