Redux/React Redux is fine. I have to use clsx to solve the problem.
(Below codes are all cases for Next.js SSR)
CASE 1 (it works!):
<Toolbar className={clsx(classes.toolbar, expanded && classes.expanded)} />
const useStyles = makeStyles(theme => ({
toolbar: {
height: 180
},
expanded: {
height: 600
}
}));
CASE 2 (it doesn't works! (my original work):
const classes = useStyles({ expanded });
<Toolbar className={classes.toolbar} />
const useStyles = makeStyles(theme => ({
toolbar: {
height: props => props.expanded ? 600 : 180
}
}));
CASE 3 (It works!):
While it's fine using styled-components like this way:
<Toolbar expanded={expanded} />
const Toolbar = styled.div`
height: ${props => props.expanded ? '600px' : '180px'};
`;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…