Skip to content

Boubaker93/react-native-img-placeholder-component

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-img-placeholder-component

A React native image component with placeholder

Feel free to add an issue if you have any trouble!

Installation

using npm

npm i --save react-native-img-placeholder-component

using yarn

yarn add react-native-img-placeholder-component

Usage

Simple example

import ImageWithPlaceholder from 'react-native-img-placeholder-component';
....
<ImageWithPlaceholder
    useNativeDriver
    style={{ width: 100, height: 100, borderRadius: 50  }}
    placeholder={require('../images/placeholder.png')}
    source={{ uri: 'https://randomuser.me/api/portraits/men/1.jpg' }}
    fadeDuration={800}
    resizeMode='cover'
/>

Example with child

import ImageWithPlaceholder from 'react-native-img-placeholder-component';
....
<ImageWithPlaceholder
    useNativeDriver
    style={{ width: 100, height: 100, borderRadius: 50  }}
    placeholder={require('../images/placeholder.png')}
    source={{ uri: 'https://randomuser.me/api/portraits/women/1.jpg' }}
    fadeDuration={800}
    resizeMode='cover'
>
    <View style={{ justifyContent: 'center', alignItems: 'center' }}>
        <Text>Hello world</Text>
    </View>
</ImageWithPlaceholder>

Options

Props Default Required? Info
source - Image source prop
placeholder - Shows placeholder if the source can't be loaded or error
style - Image and placeholder styles
fadeDuration 500 The fade duration of the placeholder once the source loads
resizeMode - Image resizeMode prop
useNativeDriver false Uses the native driver when true. Default false.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published