Last active
March 22, 2017 18:31
-
-
Save kof/3277ee04d2100bab3e6c6c33656edce7 to your computer and use it in GitHub Desktop.
Styled Primitive Components with JSS
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
import injectSheet, {jss} from 'react-jss' | |
export function createStyled(options) { | |
const sheet = jss.createStyleSheet(null, options) | |
return function styled(tag, style) { | |
const {className} = sheet.addRule(Math.random(), style) | |
const StyledComponent = props => createElement(tag, {className, ...props}) | |
return injectSheet(sheet)(StyledComponent) | |
} | |
} | |
export const styled = createStyled() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Work example:
Usage: