Использу Material-UI
Задача прокинуть пропс компонента в styles. Для этого использую makeStyles, createStyles.
на вы ходел получил ошибку
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.
const styles = makeStyles((theme: Theme) => {
return {
root: {
flexGrow: 1,
height: "100%",
},
appFrame: {
display: "flex",
flexDirection: "column",
overflow: "auto",
position: "relative",
width: "100%",
height: "100%",
minHeight: "100%",
zIndex: 1,
},
hide: {
display: "none",
},
drawerPaper: {
width: (props: any) => props.width,
},
drawerHeader: {
alignItems: "center",
display: "flex",
justifyContent: "center",
padding: "0 0px",
...theme.mixins.toolbar,
minHeight: "48px !important",
},
content: {
backgroundColor: theme.palette.background.default,
flexGrow: 1,
marginTop: theme.spacing(8),
padding: theme.spacing(3),
transition: theme.transitions.create("margin", {
duration: theme.transitions.duration.leavingScreen,
easing: theme.transitions.easing.sharp,
}),
},
"content-left": {
marginLeft: 0,
},
contentShift: {
transition: theme.transitions.create("margin", {
duration: theme.transitions.duration.enteringScreen,
easing: theme.transitions.easing.easeOut,
}),
},
"contentShift-left": {
marginLeft: drawerWidth,
},
footer: {
color: theme.palette.primary.contrastText,
background: theme.palette.primary.main,
padding: theme.spacing(1.5),
textAlign: "center",
},
footerLink: {
color: theme.palette.primary.contrastText,
fontWeight: "bolder",
"&:hover": {
color: theme.palette.primary.contrastText,
},
},
};
}) as any;
В компоненте обьявляю const classes = styles(props);