Last active
November 11, 2017 14:02
-
-
Save ArunMichaelDsouza/66da1b08db99d02e8e36b3a2b10555ab to your computer and use it in GitHub Desktop.
React 16 portals event bubbling demo
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
class Modal extends Component { | |
constructor(props) { | |
super(props); | |
} | |
render() { | |
const node = document.getElementById(‘modal’); | |
return ReactDOM.createPortal(this.props.children, node); | |
} | |
} | |
class Info extends Component { | |
constructor(props) { | |
super(props); | |
} | |
render() { | |
return ( | |
<div onClick={this.handleClick}> | |
<Modal> | |
<div> | |
Modal | |
<button>click</button> | |
</div> | |
</Modal> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment