Last active
August 9, 2018 14:07
-
-
Save gevgeny/3942b4739bf12dcdc9caf318b481df94 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 myStyled = (TargetComponent) => ([style]) => class extends React.Component { | |
componentDidMount() { | |
this.element.setAttribute('style', style); | |
} | |
render() { | |
return ( | |
<TargetComponent {...this.props} ref={element => this.element = element } /> | |
); | |
} | |
}; | |
const Button = myStyled('button')` | |
color: coral; | |
padding: 0.25rem 1rem; | |
border: solid 2px coral; | |
border-radius: 3px; | |
margin: 0.5rem; | |
font-size: 1rem; | |
`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment