Skip to content

Instantly share code, notes, and snippets.

@aofleejay
Last active May 30, 2018 17:49
Show Gist options
  • Save aofleejay/5249c405f7c6135e966dda01a83dbd65 to your computer and use it in GitHub Desktop.
Save aofleejay/5249c405f7c6135e966dda01a83dbd65 to your computer and use it in GitHub Desktop.
withLoading HOC
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