Last active
May 15, 2017 18:58
-
-
Save geetotes/f9c0e81e6489c0801cca089175ce70ab to your computer and use it in GitHub Desktop.
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
class PrettyLoader extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
loading: false | |
}; | |
this.setLoading = this.setLoading.bind(this); | |
} | |
componentDidMount() { | |
window.addEventListener('loader', this.setLoading, false); | |
} | |
componentWillUnmount() { | |
window.removeEventListener('loader', this.setLoading, false); | |
} | |
setLoading(evt) { | |
this.setState({ | |
loading: evt.detail | |
}); | |
} | |
render() { | |
let loaderStyles = classNames({ | |
'hidden': this.state.loading | |
}); | |
return( | |
<div> | |
<div className={loaderStyles} /> | |
{this.props.children} | |
</div> | |
</div> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment