npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rn-loading-image

v0.1.1

Published

test

Downloads

9

Readme

React Native Loading Image

Simple an ready to use Image Component with loading indicator, fade in animation, an no-image placeholder for error handling.

Build on top of React Native's Image component, with the same API and props.

Highly customizable.

The component is intended to be easy to use. Provide good user experience while displaying network images by taking care of all possible states: loading, error, and success.

Installation

npm install rn-loading-image

or

yarn add rn-loading-image

Usage

Import the LoadingImage component, which supports all the props of the Image component from react-native.

import React from 'react';
import { StyleSheet, View } from 'react-native';
// Import the component
import { LoadingImage } from 'rn-loading-image';

export default function App() {
  return (
    <View style={styles.container}>
      <LoadingImage
        source={{
          uri: 'https://upload.wikimedia.org/wikipedia/commons/9/9d/Golden_Gate_Bridge_.JPG',
        }}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'space-evenly',
  },
});

Customization

Change the duration of the fade in animation, the size or color of the loading indicator, no-image place holder, or provide your custom components.

import React from 'react';
import { StyleSheet, View, Text } from 'react-native';
// Import the component
import { LoadingImage } from 'rn-loading-image';

export default function App() {
  return (
    <View style={styles.container}>
      {/* Test No Image placeholder */}
      <LoadingImage
        source={{
          uri: 'https://wrong-url.com',
        }}
      />

      <LoadingImage
        source={{
          uri: 'https://p1.pxfuel.com/preview/324/157/238/scotland-united-kingdom-england-isle-of-skye.jpg',
        }}
      />

      <LoadingImage
        // Change fade in animation duration
        fadeInDuration={100}
        source={{
          uri: 'https://c0.wallpaperflare.com/preview/991/190/484/lighthouse-ushuaia-beagle-channel-argentina.jpg',
        }}
        // Change loading indicator color and size
        activityIndicatorProps={{
          color: 'red',
          size: 'large',
        }}
      />

      <LoadingImage
        fadeInDuration={2000}
        source={{
          uri: 'https://cdn.pixabay.com/photo/2020/04/12/01/58/iguazu-falls-5032457_1280.jpg',
        }}
        // Provide you custom loading indicator component
        customLoadingComponent={<Text>Loading...</Text>}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'space-evenly',
    marginTop: 50,
    marginBottom: 100,
  },
});

Using the imageStyle attribute and all the normal props of a stand Image component you can customize as much as you want

API

The component inherits all the props of the Image component from react-native.

The only difference is that the "style" props was removed, and replaced by "imageStyle" and "containerStyle" props.

Some props where added to customize the loading indicator, the no-image placeholder, and the fade in animation.

interface LoadingImageProps extends Omit<ImageProps, 'style'> {
  fadeInDuration?: number; // default value is 300 ms

  imageStyle?: StyleProp<ImageStyle>; // default height and size is 100

  containerStyle?: StyleProp<ViewStyle>; // customize the container style

  activityIndicatorProps?: React.ComponentProps<typeof ActivityIndicator>; // default color is grey and size is small

  customLoadingComponent?: React.ReactNode; // provide your custom loading component

  missingImageStyle?: StyleProp<ImageStyle>; // default height and size is  50

  customMissingImageComponent?: React.ReactNode; // provide your custom no-image placeholder component
}

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library