react-progress-button-for-images-uploader
Advanced tools
Comparing version 5.1.0 to 5.1.1
@@ -68,12 +68,27 @@ 'use strict'; | ||
}, _this.notLoading = function () { | ||
_this.setState({ currentState: STATE.NOTHING }); | ||
_this.setState({ | ||
currentState: STATE.NOTHING, | ||
prevState: _this.state.currentState | ||
}); | ||
}, _this.enable = function () { | ||
_this.setState({ currentState: STATE.NOTHING }); | ||
_this.setState({ | ||
currentState: STATE.NOTHING, | ||
prevState: _this.state.currentState | ||
}); | ||
}, _this.disable = function () { | ||
_this.setState({ currentState: STATE.DISABLED }); | ||
_this.setState({ | ||
currentState: STATE.DISABLED, | ||
prevState: _this.state.currentState | ||
}); | ||
}, _this.success = function (callback, dontRemove) { | ||
_this.setState({ currentState: STATE.SUCCESS }); | ||
_this.setState({ | ||
currentState: STATE.SUCCESS, | ||
prevState: _this.state.currentState | ||
}); | ||
_this._timeout = setTimeout(function () { | ||
if (!dontRemove) { | ||
_this.setState({ currentState: STATE.NOTHING }); | ||
_this.setState({ | ||
currentState: STATE.NOTHING, | ||
prevState: _this.state.currentState | ||
}); | ||
} | ||
@@ -86,5 +101,11 @@ callback = callback || _this.props.onSuccess; | ||
}, _this.error = function (callback) { | ||
_this.setState({ currentState: STATE.ERROR }); | ||
_this.setState({ | ||
currentState: STATE.ERROR, | ||
prevState: _this.state.currentState | ||
}); | ||
_this._timeout = setTimeout(function () { | ||
_this.setState({ currentState: STATE.NOTHING }); | ||
_this.setState({ | ||
currentState: STATE.NOTHING, | ||
prevState: _this.state.currentState | ||
}); | ||
callback = callback || _this.props.onError; | ||
@@ -99,7 +120,9 @@ if (typeof callback === 'function') { | ||
_createClass(ProgressButton, [{ | ||
key: 'componentWillReceiveProps', | ||
value: function componentWillReceiveProps(nextProps) { | ||
if (nextProps.state === this.props.state) { | ||
key: 'getDerivedStateFromProps', | ||
value: function getDerivedStateFromProps(nextProps, state) { | ||
if (nextProps.state === state.prevState) { | ||
return; | ||
} | ||
var prevState = state.prevState; | ||
switch (nextProps.state) { | ||
@@ -106,0 +129,0 @@ case STATE.SUCCESS: |
{ | ||
"name": "react-progress-button-for-images-uploader", | ||
"version": "5.1.0", | ||
"version": "5.1.1", | ||
"description": "Simple react.js component for a inline progress indicator", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -40,4 +40,5 @@ import React, { Component } from 'react' | ||
componentWillReceiveProps(nextProps) { | ||
if (nextProps.state === this.props.state) { return } | ||
getDerivedStateFromProps(nextProps, state) { | ||
if (nextProps.state === state.prevState) { return } | ||
const { prevState } = state | ||
switch (nextProps.state) { | ||
@@ -93,17 +94,34 @@ case STATE.SUCCESS: | ||
notLoading = () => { | ||
this.setState({currentState: STATE.NOTHING}) | ||
this.setState({ | ||
currentState: STATE.NOTHING, | ||
prevState: this.state.currentState, | ||
}) | ||
} | ||
enable = () => { | ||
this.setState({currentState: STATE.NOTHING}) | ||
this.setState({ | ||
currentState: STATE.NOTHING, | ||
prevState: this.state.currentState, | ||
}) | ||
} | ||
disable = () => { | ||
this.setState({currentState: STATE.DISABLED}) | ||
this.setState({ | ||
currentState: STATE.DISABLED, | ||
prevState: this.state.currentState, | ||
}) | ||
} | ||
success = (callback, dontRemove) => { | ||
this.setState({currentState: STATE.SUCCESS}) | ||
this.setState({ | ||
currentState: STATE.SUCCESS, | ||
prevState: this.state.currentState, | ||
}) | ||
this._timeout = setTimeout(() => { | ||
if (!dontRemove) { this.setState({currentState: STATE.NOTHING}) } | ||
if (!dontRemove) { | ||
this.setState({ | ||
currentState: STATE.NOTHING, | ||
prevState: this.state.currentState, | ||
}) | ||
} | ||
callback = callback || this.props.onSuccess | ||
@@ -115,5 +133,11 @@ if (typeof callback === 'function') { callback() } | ||
error = (callback) => { | ||
this.setState({currentState: STATE.ERROR}) | ||
this.setState({ | ||
currentState: STATE.ERROR, | ||
prevState: this.state.currentState, | ||
}) | ||
this._timeout = setTimeout(() => { | ||
this.setState({currentState: STATE.NOTHING}) | ||
this.setState({ | ||
currentState: STATE.NOTHING, | ||
prevState: this.state.currentState, | ||
}) | ||
callback = callback || this.props.onError | ||
@@ -120,0 +144,0 @@ if (typeof callback === 'function') { callback() } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22074
484