Skip to content

Instantly share code, notes, and snippets.

@oskardahlberg
Created May 4, 2015 12:03
Show Gist options
  • Save oskardahlberg/742103262d2217046a5b to your computer and use it in GitHub Desktop.
Save oskardahlberg/742103262d2217046a5b to your computer and use it in GitHub Desktop.
react css injection pseudo
function styler(...args) {
var result = { className: '', style: {} };
args.forEach(arg => {
var reference = getReference(arg);
var injected = reference && isInjected(reference);
if (!injected) {
Object.assign(style, arg);
if (reference) injectStyle(reference);
}
else className += ' ' + getClassName(arg);
});
return result;
};
<Component {...styler({ color: 'red' }, styleMixin(), styleRef)} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment