Skip to content

Instantly share code, notes, and snippets.

@gevgeny
Last active August 9, 2018 14:07
Show Gist options
  • Save gevgeny/3942b4739bf12dcdc9caf318b481df94 to your computer and use it in GitHub Desktop.
Save gevgeny/3942b4739bf12dcdc9caf318b481df94 to your computer and use it in GitHub Desktop.
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