Skip to content

Instantly share code, notes, and snippets.

@vnglst
Last active November 22, 2016 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vnglst/76274ad5e62382ce6a987323a8d10577 to your computer and use it in GitHub Desktop.
Save vnglst/76274ad5e62382ce6a987323a8d10577 to your computer and use it in GitHub Desktop.
ReactCasts #1
import React, { Component } from 'react';
// Returns an empty "loader" div if empty,
// Return unchanged WrappedComponent if not empty
const LoaderHOC = (WrappedComponent) => {
return class LoaderOC extends Component {
render() {
return (!this.props.question)
? <div className='loading'></div>
: <WrappedComponent {...this.props} />
}
}
}
export default LoaderHOC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment