Created
May 10, 2018 21:50
-
-
Save mchurichi/00d020dd959533e009ce2f21d92a744f to your computer and use it in GitHub Desktop.
React's Higher-Order Component to show a Semantic-UI-React Loading spinner
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, { Component } from 'react'; | |
import { Loader } from 'semantic-ui-react'; | |
const withLoader = (WrappedComponent, dataProps) => ( | |
class LoaderHOC extends Component { | |
render() { | |
const prop = this.props[dataProps]; | |
return (!prop || Object.keys(prop).length === 0) | |
? <Loader active /> | |
: <WrappedComponent {...this.props} />; | |
} | |
} | |
); | |
export default withLoader; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: