@pinwheel/react-modal
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -18,2 +18,13 @@ var React = require('react'); | ||
var addScriptTag = function addScriptTag(loadCb, url) { | ||
var tag = document.createElement('script'); | ||
tag.async = true; | ||
tag.type = 'application/javascript'; | ||
tag.src = url || 'https://cdn.getpinwheel.com/pinwheel-v1.js'; | ||
document.body.appendChild(tag); | ||
tag.addEventListener('load', function () { | ||
return loadCb(); | ||
}); | ||
}; | ||
var PinwheelModal = function PinwheelModal(_ref) { | ||
@@ -33,12 +44,14 @@ var open = _ref.open, | ||
React.useEffect(function () { | ||
var tag = document.createElement('script'); | ||
tag.async = true; | ||
tag.type = 'application/javascript'; | ||
tag.src = _srcUrl || 'https://cdn.getpinwheel.com/pinwheel-v1.js'; | ||
document.body.appendChild(tag); | ||
tag.addEventListener('load', function () { | ||
addScriptTag(function () { | ||
return setLoaded(true); | ||
}); | ||
}, _srcUrl); | ||
}, [setLoaded]); | ||
React.useEffect(function () { | ||
delete window['Pinwheel']; | ||
setLoaded(false); | ||
addScriptTag(function () { | ||
return setLoaded(true); | ||
}, _srcUrl); | ||
}, [_srcUrl, setLoaded]); | ||
React.useEffect(function () { | ||
if (!loaded) return; | ||
@@ -45,0 +58,0 @@ |
@@ -18,2 +18,13 @@ import { useState, useEffect, createElement } from 'react'; | ||
var addScriptTag = function addScriptTag(loadCb, url) { | ||
var tag = document.createElement('script'); | ||
tag.async = true; | ||
tag.type = 'application/javascript'; | ||
tag.src = url || 'https://cdn.getpinwheel.com/pinwheel-v1.js'; | ||
document.body.appendChild(tag); | ||
tag.addEventListener('load', function () { | ||
return loadCb(); | ||
}); | ||
}; | ||
var PinwheelModal = function PinwheelModal(_ref) { | ||
@@ -33,12 +44,14 @@ var open = _ref.open, | ||
useEffect(function () { | ||
var tag = document.createElement('script'); | ||
tag.async = true; | ||
tag.type = 'application/javascript'; | ||
tag.src = _srcUrl || 'https://cdn.getpinwheel.com/pinwheel-v1.js'; | ||
document.body.appendChild(tag); | ||
tag.addEventListener('load', function () { | ||
addScriptTag(function () { | ||
return setLoaded(true); | ||
}); | ||
}, _srcUrl); | ||
}, [setLoaded]); | ||
useEffect(function () { | ||
delete window['Pinwheel']; | ||
setLoaded(false); | ||
addScriptTag(function () { | ||
return setLoaded(true); | ||
}, _srcUrl); | ||
}, [_srcUrl, setLoaded]); | ||
useEffect(function () { | ||
if (!loaded) return; | ||
@@ -45,0 +58,0 @@ |
{ | ||
"name": "@pinwheel/react-modal", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "React package for Pinwheel modal", | ||
@@ -5,0 +5,0 @@ "author": "roscioli", |
Sorry, the diff of this file is not supported yet
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
14308
145