Skip to content

Instantly share code, notes, and snippets.

@kristoferbaxter
Created March 10, 2018 00:51
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • 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