Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-image-fallback

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-image-fallback - npm Package Compare versions

Comparing version 6.0.0 to 6.0.1

26

lib/index.js

@@ -5,3 +5,3 @@ "use strict";

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

@@ -12,2 +12,6 @@ Object.defineProperty(exports, "__esModule", {

var _propTypes = require("prop-types");
var _propTypes2 = _interopRequireDefault(_propTypes);
var _react = require("react");

@@ -29,3 +33,3 @@

var ReactImageFallback = (function (_Component) {
var ReactImageFallback = function (_Component) {
_inherits(ReactImageFallback, _Component);

@@ -38,3 +42,2 @@

_this.displayImage = new window.Image();
_this.state = {

@@ -50,2 +53,3 @@ imageSource: props.initialImage

value: function componentDidMount() {
this.displayImage = new window.Image();
this.setDisplayImage({ image: this.props.src, fallbacks: this.props.fallbackImage });

@@ -65,2 +69,3 @@ }

this.displayImage.onload = null;
this.displayImage = null;
}

@@ -75,3 +80,4 @@ }, {

var imagesArray = [image].concat(fallbacks);
var fallbacksArray = Array.isArray(fallbacks) ? fallbacks : [fallbacks];
var imagesArray = image ? [image].concat(fallbacksArray) : fallbacksArray;
this.displayImage.onerror = function () {

@@ -110,3 +116,3 @@ if (imagesArray.length > 2 && typeof imagesArray[1] === "string") {

return ReactImageFallback;
})(_react.Component);
}(_react.Component);

@@ -118,7 +124,7 @@ exports.default = ReactImageFallback;

ReactImageFallback.propTypes = {
src: _react.PropTypes.string.isRequired,
fallbackImage: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.element, _react.PropTypes.array]).isRequired,
initialImage: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.element]),
onLoad: _react.PropTypes.func,
onError: _react.PropTypes.func
src: _propTypes2.default.string,
fallbackImage: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.element, _propTypes2.default.array]).isRequired,
initialImage: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.element]),
onLoad: _propTypes2.default.func,
onError: _propTypes2.default.func
};

@@ -125,0 +131,0 @@

{
"name": "react-image-fallback",
"version": "6.0.0",
"version": "6.0.1",
"description": "if your image doesn't exist, fallback onto another provided image.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc