react-script-hook
Advanced tools
Comparing version 1.7.0 to 1.7.1
@@ -44,6 +44,8 @@ "use strict"; | ||
var _d = (0, react_1.useState)(status ? status.error : null), error = _d[0], setError = _d[1]; | ||
// Tracks if script is loaded so we can avoid duplicate script tags | ||
var _e = (0, react_1.useState)(false), scriptLoaded = _e[0], setScriptLoaded = _e[1]; | ||
(0, react_1.useEffect)(function () { | ||
// Nothing to do on server, or if no src specified, or | ||
// if loading has already resolved to "loaded" or "error" state. | ||
if (!isBrowser || !src || !loading || error) | ||
// if script is already loaded or "error" state. | ||
if (!isBrowser || !src || scriptLoaded || error) | ||
return; | ||
@@ -85,2 +87,3 @@ // Check again for existing <script> tags with this src | ||
setLoading(false); | ||
setScriptLoaded(true); | ||
}; | ||
@@ -87,0 +90,0 @@ var handleError = function (error) { |
{ | ||
"name": "react-script-hook", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"description": "React hook to dynamically load an external script and know when its loaded", | ||
@@ -26,3 +26,4 @@ "keywords": [ | ||
"lint": "eslint '*/**/*.{js,ts,tsx}' --report-unused-disable-directives", | ||
"prepare": "npm run build" | ||
"prepare": "npm run build", | ||
"release": "release-it" | ||
}, | ||
@@ -55,2 +56,3 @@ "peerDependencies": { | ||
"react-test-renderer": "^17.0.2", | ||
"release-it": "^15.4.1", | ||
"rimraf": "^3.0.2", | ||
@@ -60,2 +62,2 @@ "ts-jest": "^27.0.3", | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
13873
132
25