Created
October 3, 2018 06:33
-
-
Save hardyscc/6b1dfb42ecb8ec51426356703560e9bb 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
type StyleRulesCallback<ClassKey extends string = string> = ( | |
props: any, | |
theme: Theme | |
) => StyleRules<ClassKey>; | |
const withPropsStyles = (style: StyleRulesCallback) => ( | |
component: React.ComponentType<any> | |
) => { | |
return forwardRef((props, ref) => { | |
const proxy = (theme: Theme) => style(props, theme); | |
const hoc = withStyles(proxy)(component); | |
return props.children | |
? createElement(hoc, { ...props, ref }, props.children) | |
: createElement(hoc, { ...props, ref }); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment