Created
January 1, 2016 05:21
-
-
Save crobinson42/458043e2079bb1799e56 to your computer and use it in GitHub Desktop.
React-Bootstrap Modal dynamic mount/dismount from page
This file contains hidden or 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
/* | |
Create and attach | |
*/ | |
var el; | |
el = document.createElement('div'); | |
el.id = "MyReactModalView"; | |
document.getElementsByTagName('body')[0].appendChild(el); | |
ReactDOM.render(<MyReactModalView />, document.querySelector('#MyReactModalView')); | |
/* | |
Invoke this method to remove from DOM | |
*/ | |
closeModal() { | |
ReactDOM.unmountComponentAtNode(document.querySelector('#MyReactModalView')); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get this error in the console when I invoke
closeModal()