Last active
September 13, 2015 02:31
-
-
Save wwayne/6a5d67a8c3e4d9892c88 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
import cssStyle from './style' | |
componentWillUnmount () { | |
// delete the style when the component unmount | |
let tag = document.querySelector('style[id="react-tooltip"]') | |
document.getElementsByTagName('head')[0].removeChild(tag) | |
} | |
render() { | |
// to check if the style has been existed | |
if (!document.getElementsByTagName('head')[0].querySelector('style[id="react-tooltip"]')) { | |
// insert the style into the head | |
let tag = document.createElement('style') | |
tag.id = 'react-tooltip' | |
tag.innerHTML = cssStyle | |
document.getElementsByTagName('head')[0].appendChild(tag) | |
} | |
return (...) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment