From af6cd34ab46281c62aca579be709d562692c34ba Mon Sep 17 00:00:00 2001 From: tajo Date: Fri, 1 Jul 2016 21:04:42 -0700 Subject: [PATCH] fix React 15.2.0 warning about unknown closePortal prop --- lib/portal.js | 9 ++++++++- package.json | 8 ++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/portal.js b/lib/portal.js index 2eeb818..fcfb7cc 100644 --- a/lib/portal.js +++ b/lib/portal.js @@ -150,9 +150,16 @@ export default class Portal extends React.Component { // update CSS when new props arrive this.applyClassNameAndStyle(props); } + + let children = props.children; + // https://gist.github.com/jimfb/d99e0678e9da715ccf6454961ef04d1b + if (typeof props.children.type === 'function') { + children = React.cloneElement(props.children, { closePortal: this.closePortal }); + } + this.portal = ReactDOM.unstable_renderSubtreeIntoContainer( this, - React.cloneElement(props.children, { closePortal: this.closePortal }), + children, this.node, this.props.onUpdate ); diff --git a/package.json b/package.json index d0cbf23..ee65ab1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-portal", - "version": "2.2.0", + "version": "2.2.1", "description": "React component for transportation of modals, lightboxes, loading bars... to document.body", "main": "build/portal", "files": [ @@ -58,9 +58,9 @@ "jsdom": "^9.0.0", "mocha": "^2.3.4", "mocha-eslint": "^2.0.2", - "react": "^15.1.0", - "react-addons-test-utils": "^15.1.0", - "react-dom": "^15.1.0", + "react": "^15.2.0", + "react-addons-test-utils": "^15.2.0", + "react-dom": "^15.2.0", "rimraf": "^2.5.0", "sinon": "^1.17.4", "tween.js": "^16.3.1",