Skip to content

Commit

Permalink
fix React 15.2.0 warning about unknown closePortal prop
Browse files Browse the repository at this point in the history
  • Loading branch information
tajo committed Jul 2, 2016
1 parent 8554b9f commit af6cd34
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 8 additions & 1 deletion lib/portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit af6cd34

Please sign in to comment.