Last active
May 30, 2018 17:49
-
-
Save aofleejay/5249c405f7c6135e966dda01a83dbd65 to your computer and use it in GitHub Desktop.
withLoading HOC
This file contains 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 Loading from '../components/Loading' | |
const withLoading = (WrappedComponent) => { | |
return class ComponentWithLoading extends Component { | |
render() { | |
const { isLoading } = this.props | |
if (isLoading) return <Loading /> | |
return <WrappedComponent {...this.props} /> | |
} | |
} | |
} | |
export default withLoading |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment