react-portal
Advanced tools
Comparing version 4.1.4 to 4.1.5
@@ -11,3 +11,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
import PropTypes from 'prop-types'; | ||
import { createPortal } from 'react-dom'; | ||
import ReactDOM from 'react-dom'; | ||
import { canUseDOM } from './utils'; | ||
@@ -42,3 +42,3 @@ | ||
} | ||
return createPortal(this.props.children, this.props.node || this.defaultNode); | ||
return ReactDOM.createPortal(this.props.children, this.props.node || this.defaultNode); | ||
} | ||
@@ -45,0 +45,0 @@ }]); |
@@ -19,2 +19,4 @@ 'use strict'; | ||
var _reactDom2 = _interopRequireDefault(_reactDom); | ||
var _utils = require('./utils'); | ||
@@ -57,3 +59,3 @@ | ||
} | ||
return (0, _reactDom.createPortal)(this.props.children, this.props.node || this.defaultNode); | ||
return _reactDom2.default.createPortal(this.props.children, this.props.node || this.defaultNode); | ||
} | ||
@@ -60,0 +62,0 @@ }]); |
{ | ||
"name": "react-portal", | ||
"version": "4.1.4", | ||
"version": "4.1.5", | ||
"description": "To make your life with React Portals easier.", | ||
@@ -24,3 +24,3 @@ "main": "lib/index.js", | ||
"build-es": "babel ./src --out-dir ./es", | ||
"build-cjs": "BABEL_ENV=commonjs babel ./src --out-dir ./lib", | ||
"build-cjs": "cross-env BABEL_ENV=commonjs babel ./src --out-dir ./lib", | ||
"build:examples": "cross-env webpack", | ||
@@ -27,0 +27,0 @@ "clean": "rimraf es lib build", |
@@ -62,14 +62,16 @@ React-portal | ||
<PortalWithState closeOnOutsideClick closeOnEsc> | ||
{({ openPortal, closePortal, isOpen, portal }) => [ | ||
<button key="foo" onClick={openPortal}> | ||
Open Portal | ||
</button>, | ||
portal( | ||
<p> | ||
This is more advanced Portal. It handles its own state.{' '} | ||
<button onClick={closePortal}>Close me!</button>, hit ESC or | ||
click outside of me. | ||
</p> | ||
) | ||
]} | ||
{({ openPortal, closePortal, isOpen, portal }) => ( | ||
<React.Fragment> | ||
<button onClick={openPortal}> | ||
Open Portal | ||
</button> | ||
{portal( | ||
<p> | ||
This is more advanced Portal. It handles its own state.{' '} | ||
<button onClick={closePortal}>Close me!</button>, hit ESC or | ||
click outside of me. | ||
</p> | ||
)} | ||
</React.Fragment> | ||
)} | ||
</PortalWithState> | ||
@@ -96,3 +98,5 @@ ``` | ||
Also notice, that **the example returns an array since React v16 supports it**! You can also return a single component. In that case, the example would be wrapped by a div as you were used to. | ||
Also notice, that **the example returns a [Fragment](https://reactjs.org/docs/fragments.html) since React 16.2 supports it**! You can also return: | ||
- an array - available from React v16, remember to add `key` attribute | ||
- regular component - the example would be wrapped by a div, not a fragment | ||
@@ -99,0 +103,0 @@ If you start running into limits of `<PortalWithState />` (complex animations), you probably want to use `<Portal />` instead and build a component tailored to your specific taste. |
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
39157
538
132