Skip to content

Instantly share code, notes, and snippets.

@giacomorebonato
Last active August 17, 2016 12:33
Show Gist options
  • Save giacomorebonato/1c6fecde104acf28e5c67bd34b757b20 to your computer and use it in GitHub Desktop.
Save giacomorebonato/1c6fecde104acf28e5c67bd34b757b20 to your computer and use it in GitHub Desktop.
ReactJS Component with Loader
import React from 'react'
class Component_1 extends React.Component {
constructor (props) {
super(props)
this.state = {
loading: true
}
}
componentDidMount () {
setTimeout(() => {
this.setState({ loading: false })
}, 1000)
}
render () {
if (this.state.loading) {
return (
<div>
<img src='/img/loader.gif' />
</div>
)
}
return (
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment