I'm trying to migrate some of my React components to the new makeStyles/useStyles hook API from Material UI. If I understand correctly I can keep accepting classes as a prop from parent components as long as I pass the props to useStyles:
const MyComponent = (props: Props) => {
const { myProp } = props;
const classes = useStyles(props);
I was wondering how to declare my Props type in that case. The equivalent with the HOC API being:
const styles = createStyles({
a: {},
b: {}
});
interface Props extends WithStyles<typeof styles> {
myProp: string;
}
Here is something that works but looks a bit verbose:
const styles = createStyles({
a: {},
b: {}
});
interface Props extends StyledComponentProps<ClassKeyOfStyles<typeof styles>> {
myProp: string;
}
const useStyles = makeStyles(styles);
Is there a better way? Ideally without the need for createStyles and using makeStyles inline with the styles declaration.