Skip to content

Instantly share code, notes, and snippets.

@ArunMichaelDsouza
Last active November 11, 2017 14:02
Show Gist options
  • Save ArunMichaelDsouza/66da1b08db99d02e8e36b3a2b10555ab to your computer and use it in GitHub Desktop.
Save ArunMichaelDsouza/66da1b08db99d02e8e36b3a2b10555ab to your computer and use it in GitHub Desktop.
React 16 portals event bubbling demo
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