Skip to content

Instantly share code, notes, and snippets.

@kristoferbaxter
Created March 10, 2018 00:51
Show Gist options
  • Save kristoferbaxter/585a43e694772cef993f598a05f8ace1 to your computer and use it in GitHub Desktop.
Save kristoferbaxter/585a43e694772cef993f598a05f8ace1 to your computer and use it in GitHub Desktop.
export class MyComponent extends React.Component {
componentWillMount() {
const styleid = 'MyComponentStyles'
if (document.head.querySelector(`#${styleid}`) !== null) {
const styles = document.createElement('style');
styles.id = styleid;
styles.append('[foo]{ color: blue; }');
document.head.appendChild(styles);
}
}
render() {
return (
<div foo>
<p>Awesome</p>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment