Last active
August 17, 2016 12:33
-
-
Save giacomorebonato/1c6fecde104acf28e5c67bd34b757b20 to your computer and use it in GitHub Desktop.
ReactJS Component with Loader
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
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