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

react-lazy-card

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-lazy-card - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

import React, { Component, PropTypes } from 'react'
import classNames from 'classnames'
import autoBind from 'react-auto-bind'
import shallowCompare from 'react-addons-shallow-compare'
export default class LazyCard extends Component {
constructor (props) {
super(props)
constructor (props, context) {
super(props, context)
this.state = {
image: props.lazyLoad ? props.defaultImage : (props.defaultImage || props.image),
width: 0
image: props.lazyLoad ? props.defaultImage : (props.defaultImage || props.image)
}

@@ -20,6 +20,4 @@

componentWillReceiveProps (nextProps) {
this.setState({
width: nextProps.width
})
shouldComponentUpdate (nextProps, nextState) {
return shallowCompare(this, nextProps, nextState)
}

@@ -72,3 +70,3 @@

// width of slide
// width of slide component
width: PropTypes.number,

@@ -79,3 +77,3 @@

// url of pre loaded image
// url of placeholder image
defaultImage: PropTypes.string,

@@ -85,2 +83,3 @@

// serves similar to alt attribute for image
// only for the purpose of SEO
title: PropTypes.string,

@@ -87,0 +86,0 @@

@@ -23,2 +23,6 @@ 'use strict';

var _reactAddonsShallowCompare = require('react-addons-shallow-compare');
var _reactAddonsShallowCompare2 = _interopRequireDefault(_reactAddonsShallowCompare);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -35,10 +39,9 @@

function LazyCard(props) {
function LazyCard(props, context) {
_classCallCheck(this, LazyCard);
var _this = _possibleConstructorReturn(this, (LazyCard.__proto__ || Object.getPrototypeOf(LazyCard)).call(this, props));
var _this = _possibleConstructorReturn(this, (LazyCard.__proto__ || Object.getPrototypeOf(LazyCard)).call(this, props, context));
_this.state = {
image: props.lazyLoad ? props.defaultImage : props.defaultImage || props.image,
width: 0
image: props.lazyLoad ? props.defaultImage : props.defaultImage || props.image
};

@@ -56,7 +59,5 @@

}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
this.setState({
width: nextProps.width
});
key: 'shouldComponentUpdate',
value: function shouldComponentUpdate(nextProps, nextState) {
return (0, _reactAddonsShallowCompare2.default)(this, nextProps, nextState);
}

@@ -128,3 +129,3 @@ }, {

// width of slide
// width of slide component
width: _react.PropTypes.number,

@@ -135,3 +136,3 @@

// url of pre loaded image
// url of placeholder image
defaultImage: _react.PropTypes.string,

@@ -141,2 +142,3 @@

// serves similar to alt attribute for image
// only for the purpose of SEO
title: _react.PropTypes.string,

@@ -143,0 +145,0 @@

@@ -83,2 +83,3 @@ {

"react": "^15.x.x",
"react-addons-shallow-compare": "^15.3.2",
"react-auto-bind": "^0.2.0"

@@ -91,3 +92,3 @@ },

},
"version": "0.1.2"
"version": "0.1.3"
}