Last active
June 19, 2017 02:27
-
-
Save geetotes/fa4ed73eb90a98af711f510ddf5c825a 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
import React from 'react'; | |
import { connect } from 'react-redux'; | |
class PrettyLoader extends React.Component { | |
_show() { | |
// Don't forget that loading can be any data type you want! | |
if (this.props.loading === true) { | |
return ( | |
<div className="loading"> | |
<img src="crazyLoading.gif" /> | |
</div> | |
); | |
} else { | |
return this.props.children; | |
} | |
} | |
render() { | |
return ( | |
<div> | |
{this._show()} | |
</div> | |
); | |
} | |
} | |
function mapStateToProps(state) { | |
return { | |
loading: state.loading | |
}; | |
} | |
export default connect(mapStateToProps) (PrettyLoader); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment