• Stars
    star
    111
  • Rank 314,510 (Top 7 %)
  • Language
    JavaScript
  • Created over 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

stop displaying broken images, have another image to fallback on.

React Image Fallback

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

Circle CI TypeScript definitions on DefinitelyTyped

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. Optionally this can also be passed in as a react element. This can also be passed in as an array of string srcs or react elements, the component will attempt to keep trying srcs until a loadable src is found. It should be noted that a react element will always be treated as a loadable src.

Optional Props

initialImage

The image to show before your src or fallbackImage load. Can optionally be passed in as a react element.

initialTimeout

timeout in millisecond before to show initialImage. Default is null which should initialImage immediately

onLoad

A callback called if initial image loads successfully, will be called with successful image url.

onError

A callback called if initial image load fails, will be called with failing image url.

spread props

This component also utilizes jsx spread attributes to pass along custom image attributes such as alt tags and className. Only valid dom props will be spread to the image tag.

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>
		);
	}
}

Copyright (C) 2017 Social Tables, Inc. (https://www.socialtables.com) All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

react-user-tour

Give your user a guided tour around your application
JavaScript
151
star
2

redux-unhandled-action

Redux middleware that logs an error to the console when an action is fired and the state is not mutated,
JavaScript
125
star
3

react-infinity-menu

A react component that displays an unlimited deep menu
JavaScript
58
star
4

openfpc

A 2D CAD tool built on React, Three.js, and Immutable
JavaScript
51
star
5

graphql-test-generator

generate tests for graphql
JavaScript
29
star
6

saml-protocol

A framework-agnostic SAML protocol implementation for service and identity providers
JavaScript
16
star
7

2019-drawing-app-challenge

Make a drawing app! Challenge for prospective apprentices.
JavaScript
9
star
8

ST-UI-Toolkit

DEPRECATED - Old React Component Toolkit for ST
JavaScript
8
star
9

obj2json

Convert Wavefront .obj files to Three.js JSON format, using Blender
JavaScript
7
star
10

webgl-test-ci

Test your WebGL on CI(continuous integration)
JavaScript
7
star
11

apprentice-challenge

Social Tables Apprentice Challenge
JavaScript
7
star
12

drawing-app-challenge

Make a drawing app! A challenge for prospective apprentices.
JavaScript
7
star
13

chrome-prettier

HTML
7
star
14

connect-four

JavaScript
6
star
15

react-spectrum

react-color with a whole spectrum of bug fixes
JavaScript
5
star
16

filter-invalid-dom-props

A simple helper function to filter out invalid DOM properties
JavaScript
5
star
17

venue-app-challenge

Make a venue listing page! A challenge for prospective apprentices.
JavaScript
5
star
18

react-on-click-out

a component to execute a function when clicking outside of a node
JavaScript
4
star
19

catalyst

A framework to speed up and ease development in React.
JavaScript
4
star
20

react-should-show

a higher order component to control rendering of children
JavaScript
3
star
21

react-native-compose-styles

JavaScript
3
star
22

most-prs-merged

Simple Node Command-line app that uses Github SDK to generate a list of who merged the most PRs
JavaScript
3
star
23

detect-zoom

JavaScript
3
star
24

largest-rect-in-poly

JavaScript
3
star
25

create-webpack-split-point-atom

An atom plugin to use create-webpack-split-point
JavaScript
3
star
26

socket.io-store

Redis-backed store functionality, like socket.io pre-v1.x
JavaScript
3
star
27

NSString-STUnderCase

Convert an `NSString` from underscore_case to camelCase, and vice versa.
Ruby
2
star
28

maximal-rectangle

javascript module to solve the maximal rectangle problem.
JavaScript
2
star
29

create-webpack-split-point

abstract away creation of React Component that will be asynchronously loaded through System.import in componentDidMount
JavaScript
2
star
30

geometry-utils

utility functions for calculating 2D geometry. Used in api, maximal-rectangle
JavaScript
2
star
31

platform-challenge

Social Tables Intern Challenge
JavaScript
2
star
32

react-paged-table

React table component with in-memory paging
JavaScript
1
star
33

slambdack

Slack Helpers for AWS Lambda
JavaScript
1
star
34

docker-mysql57

MySQL 5.7 - Social Tables Style
1
star
35

docker-redis

Redis - Social Tables Style
1
star
36

socialtables.github.io

https://socialtables.github.io
JavaScript
1
star
37

offload

this is NOT a job queue
JavaScript
1
star
38

example-app

Example application for third-party app developers integrating with Social Tables
JavaScript
1
star
39

intern-challenge

Social Tables Intern Challlenge
JavaScript
1
star
40

whitesource-config

Configuration for Whitesource aka Mend security scanning
1
star