1.1.1 • Published 4 years ago

react-css-modules-psh v1.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

React CSS modules: Partially applied styles HOC

In case you need to get a higher-order component with the styles already provided, you can do it that way:

import styles from './styles/Component.module.css';
import withStyles from 'react-css-modules-psh';

type OwnProps = { /* props. */ };

const Component: React.FC<OwnProps> = () => (
  <div styleName='Component' />
);

const withStylesApplied = withStyles(styles);
export default withStylesApplied;

You can also pass the result of the function to Redux compose function:

export default compose<React.Component<OwnProps>>(
  // ...,
  connect(mapStateToProps, mapDispatchToProps),
  withStyles(styles) // Need to be the first one.
)(Component);

That only works for functional components.