Skip to content

Instantly share code, notes, and snippets.

@robinweser
Created June 21, 2017 07:39
Show Gist options
  • Save robinweser/506adbbc9a647cfa3f231e9494089e7e to your computer and use it in GitHub Desktop.
Save robinweser/506adbbc9a647cfa3f231e9494089e7e to your computer and use it in GitHub Desktop.
// before
const rule = ({ fontSize, color }) => ({
fontSize: fontSize,
color: color,
backgroundColor: 'black',
lineHeight: 1.0,
':hover': {
color: 'red'
},
'@media (min-width: 300px)' {
backgroundColor: 'yellow',
color: 'green'
}
})
// after
const rule = ({ fontSize, color }, renderer) => {
// some one time condition
if (!renderer.precompiled[UNIQUE_ID]) {
renderer.precompiled[UNIQUE_ID] = // render rules etc.
}
return {
_className: renderer.precompiled[UNIQUE_ID],
fontSize: fontSize,
color: color
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment