JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16903
  • Score
    100M100P100Q134433F
  • License ISC

if your image doesn't exist, fallback onto another provided image.

Package Exports

  • react-image-fallback

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-image-fallback) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

React Image Fallback

React Image Fallback exists for those times that you're just not sure an image will be there.

Install

npm install react-image-fallback

Required Props

src

A string represent the url to your primary image.

fallbackImage

A string representing the image you want to fallback to if your primary image is not there.

Optional Props

initialImage

The image to show before your src or fallbackImage load.

spread props

This component also utilizes jsx spread attributes to pass along custom image attributes such as alt tags and className

Use

import React From "react";
import ReactImageFallback from "react-image-fallback";
export default class ShowImage extends React.Component {
    render() {
        return (
            <div>
                <ReactImageFallback
                    src="my-image.png"
                    fallbackImage="my-backup.png"
                    initialImage="loader.gif"
                    alt="cool image should be here"
                    className="my-image" />
            </div>
        );
    }
}