Coder Social home page Coder Social logo

react-native-placeholderimage's Introduction

React-Native PlaceHolderImage Component : react-native-placeholderimage

version

Preface

Are you struggling with placeholder images in react native and seeking some solution to put placeholder until your image is not downloaded from internet, you are on a right repository.

Features

  • Until image is not loaded from the given URL, some placeholder required to show that empty space.
  • No placeholder image pass, then behave like react-native image.
  • ease to implement and use.

Installation

  • Run this command $ npm install react-native-placeholderimage --save

Implementation

  • import in js file as import PlaceHolderImage from 'react-native-placeholderimage'; see example
import React, { Component } from 'react';
import { View, StyleSheet, AppRegistry } from 'react-native';
import PlaceHolderImage from 'react-native-placeholderimage';

export default class PlaceHolderImageViewDemo extends Component {
	render() {
		return (
			<View style={styles.container}>
				<PlaceHolderImage
					style={{ height: 100, width: 100, alignSelf: 'center', justifyContent: 'center' }}
					source={{ uri: 'https://images4.alphacoders.com/171/thumb-1920-171916.jpg' }}
					placeHolderURI={{ uri: 'place_holder_image' }}
					placeHolderStyle={{ height: 100, width: 100, backgroundColor: 'blue' }}
				/>
			</View>
		);
	}
}

const styles = StyleSheet.create({
	container: {
		flex: 1,
		justifyContent: 'center',
		alignItems: 'center',
		backgroundColor: '#F5FCFF'
	}
});

AppRegistry.registerComponent('PlaceHolderImageView', () => PlaceHolderImageViewDemo);

Pass this Two props for Visible PlaceHolder

  • this.props.placeHolderURI
  • this.props.placeHolderStyle

Available props

  1. all image props
  2. placeHolderURI : image object as { uri: 'place_holder_image' }
  3. *placeHolderStyle : style object as { height: 100, width: 100, backgroundColor: 'blue' }

*placeholder image style merge as (style + placeHolderStyle + centerImageStyle)

Feedbacks

  • I love to hear your valuable feedbacks, suggestions & issues. Please raise a issue on the repo or email me (as subject: 'placeholderimage#issue <topic>') @ [email protected].

❤️ Voila! Happy coding...

react-native-placeholderimage's People

Contributors

akshayarorags avatar ishantsagar avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.