React Native How to LazyLoad image

Waleed Arshad picture Waleed Arshad · Aug 3, 2016 · Viewed 13.4k times · Source

I have a listview where i want to show image on each row and I don't want to show whole 25 images at once. I just wanted to load image which come in viewport.

I am getting url in props

<Image source={{uri: this.props.media.image_url}} 
       style={{ width:this.props.media.width,
       height: this.props.media.height}}
/>

How can I achieve this in react native. Note: I have tried these library but none working for me. Probably the version issue that it has written for old version of react Plus some of it does not work with dynamic props

react-native-lazyload

react-lazy-load

Answer

Overcomer picture Overcomer · Mar 24, 2019

You can use react native elements.

Add to project: npm install --save react-native-elements

Usage:

import { ActivityIndicator } from 'react-native';
import { Image } from 'react-native-elements';

// Standard Image
<Image
  source={{ uri: image }}
  style={{ width: 200, height: 200 }}
/>


// Image with custom placeholder content
<Image
  source={{ uri: image }}
  style={{ width: 200, height: 200 }}
  PlaceholderContent={<ActivityIndicator />}
/>

Source: react native elements