Created
June 21, 2017 07:39
-
-
Save robinweser/506adbbc9a647cfa3f231e9494089e7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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