EDIT: Reproducible bug https://github.com/ganavol409/next-material-ui-classes-bug
Seems to occur with with HoC components and both importing useStyles from Material UI
What has been implemented:
https://github.com/mui-org/material-ui/blob/master/examples/nextjs/pages/_document.js + next js project with material ui and material styles
Current behaviour:
Page css (specifically 'classes' field in Material UI) doesn't load upon coming from Next JS Link/Next JS Router module. After the refresh 'classes' field loads
Expected behaviour:
All of css loading if user comes from Next JS Link/Next JS Router module or types in website address manually (currently only works if user manually writes it or refreshes the website/page)
Code:
<Container maxWidth="sm" disableGutters classes={{ maxWidthSm: classes.smContainerWidth }}>
...
</Container>
smContainerWidth: {
maxWidth: '750px'
},
useEffect(() => {
router.push('/');
}, []);
The container will load default 600px width if user comes from Next JS Link/Next JS Router instead of 750px and after user refreshes container will be 750px width
automatic router push