Created
December 28, 2017 23:11
-
-
Save oliviertassinari/dceb407e99d7279cc4228957c068d27c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 React from 'react'; | |
import classNames from 'classnames'; | |
import PropTypes from 'prop-types'; | |
function stylifier(higherOrderComponent) { | |
return Component => styles => { | |
function StyledComponent(props) { | |
const { classes, className, ...other } = props; | |
return <Component className={classNames(classes.root, className)} {...other} />; | |
} | |
StyledComponent.propTypes = { | |
classes: PropTypes.object.isRequired, | |
className: PropTypes.string, | |
}; | |
return higherOrderComponent({ | |
root: styles, | |
})(StyledComponent); | |
}; | |
} | |
export default stylifier; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example of usage: https://twitter.com/olivtassinari/status/946517606009274369