Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

sqivea/react-css-modules-psh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Partially applied styles higher-order component for react-css-modules

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published