Skip to content

Instantly share code, notes, and snippets.

@codemilli
Last active May 18, 2018 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codemilli/91fc2b5cac5479c3fbeeae1ea7edb793 to your computer and use it in GitHub Desktop.
Save codemilli/91fc2b5cac5479c3fbeeae1ea7edb793 to your computer and use it in GitHub Desktop.
test
import React from 'react'
class ContainerComponent extends React.Component {
constructor(props) {
super(props)
this.state = {
loaded: false
}
}
componentDidMount() {
const sheet = document.createElement('link')
sheet.rel = 'stylesheet'
sheet.href = 'http://css.com'
sheet.type = 'text/css'
sheet.onload = () => {
this.setState({loaded: true})
}
document.head.appendChild(sheet)
}
render() {
const {children} = this.props
const {loaded} = this.state
return (
<div>
{loaded ? children : null}
</div>
)
}
}
export default ContainerComponent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment