Skip to content

Instantly share code, notes, and snippets.

@VinSpee
Forked from kristoferbaxter/example.jsx
Created March 10, 2018 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VinSpee/eba64ce9956fe38dd2b57ba2ff9e86ee to your computer and use it in GitHub Desktop.
Save VinSpee/eba64ce9956fe38dd2b57ba2ff9e86ee 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