Skip to content

Instantly share code, notes, and snippets.

@ArunMichaelDsouza
Created November 11, 2017 13:28
Show Gist options
  • Save ArunMichaelDsouza/e6671b254f2c2fccf86c27cfcbe5f73c to your computer and use it in GitHub Desktop.
Save ArunMichaelDsouza/e6671b254f2c2fccf86c27cfcbe5f73c to your computer and use it in GitHub Desktop.
React 16 portals demo
class Info extends Component {
constructor(props) {
super(props);
}
render() {
return <Modal><Text text=“This is the text” /></Modal>;
}
}
class Modal extends Component {
constructor(props) {
super(props);
}
render() {
const node = document.getElementById(‘modal’);
return ReactDOM.createPortal(this.props.children, node);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment