Comparing version 7.3.0 to 7.3.1
@@ -17,7 +17,13 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
useEffect(function () { | ||
var isCurrentSrc = true; | ||
isImageValid(src).then(function (isValid) { | ||
if (!isValid) { | ||
// https://github.com/ant-design/ant-design/issues/44948 | ||
// If src changes, the previous setStatus should not be triggered | ||
if (!isValid && isCurrentSrc) { | ||
setStatus('error'); | ||
} | ||
}); | ||
return function () { | ||
isCurrentSrc = false; | ||
}; | ||
}, [src]); | ||
@@ -36,6 +42,3 @@ useEffect(function () { | ||
isLoaded.current = false; | ||
if (status !== 'loading') { | ||
return; | ||
} | ||
if (img !== null && img !== void 0 && img.complete && (img.naturalWidth || img.naturalHeight)) { | ||
if (status === 'loading' && img !== null && img !== void 0 && img.complete && (img.naturalWidth || img.naturalHeight)) { | ||
isLoaded.current = true; | ||
@@ -42,0 +45,0 @@ onLoad(); |
@@ -24,7 +24,13 @@ "use strict"; | ||
(0, _react.useEffect)(function () { | ||
var isCurrentSrc = true; | ||
(0, _util.isImageValid)(src).then(function (isValid) { | ||
if (!isValid) { | ||
// https://github.com/ant-design/ant-design/issues/44948 | ||
// If src changes, the previous setStatus should not be triggered | ||
if (!isValid && isCurrentSrc) { | ||
setStatus('error'); | ||
} | ||
}); | ||
return function () { | ||
isCurrentSrc = false; | ||
}; | ||
}, [src]); | ||
@@ -43,6 +49,3 @@ (0, _react.useEffect)(function () { | ||
isLoaded.current = false; | ||
if (status !== 'loading') { | ||
return; | ||
} | ||
if (img !== null && img !== void 0 && img.complete && (img.naturalWidth || img.naturalHeight)) { | ||
if (status === 'loading' && img !== null && img !== void 0 && img.complete && (img.naturalWidth || img.naturalHeight)) { | ||
isLoaded.current = true; | ||
@@ -49,0 +52,0 @@ onLoad(); |
{ | ||
"name": "rc-image", | ||
"version": "7.3.0", | ||
"version": "7.3.1", | ||
"description": "React easy to use image component", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
139621
3200