Created
June 12, 2020 22:59
-
-
Save KonradSzwarc/35fed2d4d34e3dcaf47166a65842984e to your computer and use it in GitHub Desktop.
Custom implementation of the Material UI makeStyles function that uses a custom Theme type.
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 makeMuiStyles from '@material-ui/styles/makeStyles'; | |
| import { ClassNameMap, Styles, WithStylesOptions } from '@material-ui/styles/withStyles'; | |
| import { Theme } from './types'; | |
| export const makeStyles = <Props extends {} | undefined = undefined, ClassKey extends string = string>( | |
| styles: Styles<Theme, Props extends undefined ? {} : Props, ClassKey>, | |
| options?: Omit<WithStylesOptions<Theme>, 'withTheme'>, | |
| ) => { | |
| return makeMuiStyles(styles, options) as Props extends undefined | |
| ? (props?: any) => ClassNameMap<ClassKey> | |
| : (props: Props) => ClassNameMap<ClassKey>; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment