import React, {PropTypes} from 'react';
import ReactDOM from 'react-dom';

class Portal extends React.Component {
  componentDidMount() {
    this.nodeEl = document.createElement('div');
    document.body.appendChild(this.nodeEl);
    this.renderChildren(this.props);
  }

  componentWillUnmount() {
    ReactDOM.unmountComponentAtNode(this.nodeEl);
    document.body.removeChild(this.nodeEl);
  }

  componentWillReceiveProps(nextProps) {
    this.renderChildren(nextProps);
  }

  renderChildren(props) {
    ReactDOM.render(props.children, this.nodeEl);
  }

  render() {
    return null;
  }
}

Portal.propTypes = {
  children: PropTypes.node.isRequired
};

module.exports = Portal;

@@ -496,24 +496,114 @@
 en(props) %7B%0A
+    let %7Bchildren%7D = props;%0A%0A    if (children == null) %7B%0A      children = %3Cdiv /%3E;%0A    %7D%0A%0A
     ReactDOM
@@ -614,14 +614,8 @@
 der(
-props.
 chil
@@ -623,32 +623,53 @@
 ren, this.nodeEl
+, this.props.onRender
 );%0A  %7D%0A%0A  render
@@ -748,19 +748,36 @@
 node
-.isRequired
+,%0A  onRender: PropTypes.func
 %0A%7D;%0A

Allow passing null to Portal children and render callback