Created
May 15, 2017 19:26
-
-
Save gigobyte/f0de8ffd9a4dcf4c11bedfe4bd8185d1 to your computer and use it in GitHub Desktop.
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
const styleable = (ParentComponent) => class extends ParentComponent { | |
static displayName = `Styleable(${ParentComponent.displayName || ParentComponent.name})` | |
render() { | |
const originalElement = super.render() | |
const className = `${originalElement.props.className} ${this.props.className}` | |
const style = {...originalElement.props.style, ...this.props.style} | |
const newProps = {...originalElement.props, className, style} | |
return React.cloneElement(originalElement, newProps) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment