To clarify, my development environment is using MUI version 4.12.3. Inside file A, I have a simplified code snippet for a functional component, along with the usage of makeStyles
to style a JSX element within the return statement (not displayed here). Everything functions correctly in this scenario.
const useStyles = makeStyles((theme) => ({
content: {
minHeight: '100vh',
},
}));
Now, moving on to file B, the objective is to modify the CSS class content
based on the value of isDesktop
. Is it feasible or recommended to do so? Below is an attempt that didn't yield the expected outcome:
const useStyles = makeStyles({
content: {
minHeight: (props) => (props.isDesktop ? '100vh' : '112vh'),
},
});
//And within the functional component:
const isDesktop = useMediaQuery(Theme.breakpoints.up('sm'));
const classes = useStyles({ isDesktop });
It's important to note that the primary goal in file B is to alter the CSS class content
, without rendering the JSX component. The classes
variable remains unused in this context as shown above.