Course contentsShow
← React Native
Lesson 221 of 1,5553. Core Primitive ComponentsFree lesson

Creating Progressive Image Loaders

Learners will show blurred placeholders while high-resolution media fetches over the network.

Creating Progressive Image Loaders

In this lesson, you will learn how to improve perceived performance by showing a blurred, low-resolution placeholder while your high-resolution images load over the network.

When a user opens an app, waiting for a high-quality image to download can feel sluggish, often leaving the user staring at an empty white space. A Progressive Image Loader solves this by stacking two images on top of each other: a tiny, blurred "preview" that loads instantly, and the full-resolution image that fades in once it arrives.

How it works

Think of this like a digital painting. You start with a blurry sketch (the preview) and then layer the detailed masterpiece on top once the file finishes downloading. In React Native, we can achieve this using the Image component.

By setting the preview image to render first and then using the onLoad prop to trigger a transition, we create a smooth user experience.

import React, { useState } from 'react';
import { View, Image, StyleSheet } from 'react-native';

const ProgressiveImage = ({ previewSource, source }) => {
  const [isLoaded, setIsLoaded] = useState(false);

  return (
    <View style={styles.container}>
      {/* The blurred placeholder */}
      <Image source={previewSource} style={styles.image} blurRadius={10} />
      
      {/* The high-res image */}
      <Image 
        source={source} 
        style={[styles.image, { opacity: isLoaded ? 1 : 0 }]} 
        onLoad={() => setIsLoaded(true)} 
      />
    </View>
  );
};

Why use this?

When the source image begins fetching, the previewSource (which should be a very small file stored locally or cached) is already visible. Because it has a blurRadius, the lack of detail is hidden, and the user perceives the content as "loading" immediately rather than "missing." Once the high-res file arrives, the onLoad callback flips our state, revealing the crisp image underneath. This prevents "pop-in" jitter and makes your app feel significantly faster.

Key Takeaway: By layering a blurred placeholder behind your main image and toggling opacity once the network request completes, you bridge the gap between user interaction and media display.