Created
November 21, 2017 20:38
-
-
Save DiegoPinho/76a638fdec3b9e1da976309ae153c895 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const modal = document.getElementById('modal'); | |
class Modal extends React.Component { | |
constructor(props) { | |
super(props); | |
this.el = document.createElement('div'); | |
} | |
componentDidMount() { | |
modal.appendChild(this.el); | |
} | |
componentWillUnmount() { | |
modal.removeChild(this.el); | |
} | |
render() { | |
return ReactDOM.createPortal(this.props.children,this.el); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment