Skip to content

Instantly share code, notes, and snippets.

@fakenickels
Created November 7, 2017 18:35
Show Gist options
  • Save fakenickels/2ddcd13b6efde76e5dfd00459cd1f91c to your computer and use it in GitHub Desktop.
Save fakenickels/2ddcd13b6efde76e5dfd00459cd1f91c to your computer and use it in GitHub Desktop.
const withPromise = R.curry((propName, promise, Component) => class WithPromise extends React.Component { state = { [propName]: null } displayName = `WithPromise(${Component.displayName})` componentDidMount = () => promise(this.props).then(value => this.setState({ [propName]: value })).catch(something) render = () => <Component {...this.props} {this.state}/> })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment