Skip to content

Instantly share code, notes, and snippets.

@wwayne
Last active September 13, 2015 02:31

Revisions

  1. wwayne revised this gist Sep 13, 2015. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,15 @@
    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
  2. wwayne renamed this gist Sep 13, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. wwayne created this gist Sep 13, 2015.
    16 changes: 16 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    import cssStyle from './style'

    componentWillUnmount () {
    let tag = document.querySelector('style[id="react-tooltip"]')
    document.getElementsByTagName('head')[0].removeChild(tag)
    }

    render() {
    if (!document.getElementsByTagName('head')[0].querySelector('style[id="react-tooltip"]')) {
    let tag = document.createElement('style')
    tag.id = 'react-tooltip'
    tag.innerHTML = cssStyle
    document.getElementsByTagName('head')[0].appendChild(tag)
    }
    return (...)
    }