@reach/portal
Advanced tools
Comparing version 0.6.1 to 0.6.2
@@ -5,3 +5,3 @@ import React from "react"; | ||
var Portal = function Portal(_ref) { | ||
function Portal(_ref) { | ||
var children = _ref.children, | ||
@@ -46,4 +46,5 @@ _ref$type = _ref.type, | ||
}); | ||
}; | ||
} | ||
Portal.displayName = "Portal"; | ||
export default Portal; |
@@ -14,3 +14,3 @@ "use strict"; | ||
var Portal = function Portal(_ref) { | ||
function Portal(_ref) { | ||
var children = _ref.children, | ||
@@ -55,5 +55,6 @@ _ref$type = _ref.type, | ||
}); | ||
}; | ||
} | ||
Portal.displayName = "Portal"; | ||
var _default = Portal; | ||
exports["default"] = _default; |
{ | ||
"name": "@reach/portal", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"description": "Declarative portals for React", | ||
@@ -11,3 +11,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"@reach/component-component": "^0.6.1" | ||
"@reach/component-component": "^0.6.2" | ||
}, | ||
@@ -28,3 +28,3 @@ "peerDependencies": { | ||
], | ||
"gitHead": "c1e249448a3672ccc65698218f0f38ef9814ab90" | ||
"gitHead": "00e73c5da6d25f50194612f74de71156fde2a80a" | ||
} |
@@ -5,27 +5,31 @@ import React from "react"; | ||
let Portal = ({ children, type = "reach-portal" }) => ( | ||
<Component | ||
getRefs={() => ({ mountNode: null, portalNode: null })} | ||
didMount={({ refs, forceUpdate }) => { | ||
// It's possible that the content we are portal has, itself, been portaled. | ||
// In that case, it's important to append to the correct document element. | ||
const ownerDocument = refs.mountNode.ownerDocument; | ||
refs.portalNode = ownerDocument.createElement(type); | ||
ownerDocument.body.appendChild(refs.portalNode); | ||
forceUpdate(); | ||
}} | ||
willUnmount={({ refs: { portalNode } }) => { | ||
portalNode.ownerDocument.body.removeChild(portalNode); | ||
}} | ||
render={({ refs }) => { | ||
const { portalNode } = refs; | ||
if (!portalNode) { | ||
return <div ref={div => (refs.mountNode = div)} />; | ||
} else { | ||
return createPortal(children, portalNode); | ||
} | ||
}} | ||
/> | ||
); | ||
function Portal({ children, type = "reach-portal" }) { | ||
return ( | ||
<Component | ||
getRefs={() => ({ mountNode: null, portalNode: null })} | ||
didMount={({ refs, forceUpdate }) => { | ||
// It's possible that the content we are portal has, itself, been portaled. | ||
// In that case, it's important to append to the correct document element. | ||
const ownerDocument = refs.mountNode.ownerDocument; | ||
refs.portalNode = ownerDocument.createElement(type); | ||
ownerDocument.body.appendChild(refs.portalNode); | ||
forceUpdate(); | ||
}} | ||
willUnmount={({ refs: { portalNode } }) => { | ||
portalNode.ownerDocument.body.removeChild(portalNode); | ||
}} | ||
render={({ refs }) => { | ||
const { portalNode } = refs; | ||
if (!portalNode) { | ||
return <div ref={div => (refs.mountNode = div)} />; | ||
} else { | ||
return createPortal(children, portalNode); | ||
} | ||
}} | ||
/> | ||
); | ||
} | ||
Portal.displayName = "Portal"; | ||
export default Portal; |
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
7172
157