Skip to content

Instantly share code, notes, and snippets.

@oliviertassinari
Created December 28, 2017 23:11
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oliviertassinari/dceb407e99d7279cc4228957c068d27c to your computer and use it in GitHub Desktop.
Save oliviertassinari/dceb407e99d7279cc4228957c068d27c to your computer and use it in GitHub Desktop.
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;
@oliviertassinari
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment