Skip to content

Instantly share code, notes, and snippets.

@geetotes
Last active June 19, 2017 02:27
Show Gist options
  • Save geetotes/fa4ed73eb90a98af711f510ddf5c825a to your computer and use it in GitHub Desktop.
Save geetotes/fa4ed73eb90a98af711f510ddf5c825a to your computer and use it in GitHub Desktop.
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