I have started using MUI v5 with makeStyles in my previous project. After deploying, I faced a huge delay in loading page's CSS. So I started searching that found out makeStyles
is deprecated in MUI v5.
MUI suggests to use sx
prop instead. That's fine. But the problem here is I don't want to write my JSX and CSS/JSS code together. For example:
This is what MUI says:
// App.js
function App() {
return (
<Grid sx={{ bgcolor: 'yellow', mx: 5, pt: 2, border: 1 }}>
This is a test!
</Grid>
);
}
export default App;
Below is somehow what I expect:
// style.js
export default {
myGrid: {
bgcolor: 'yellow',
mx: 5,
pt: 2,
border: 1,
},
};
// App.js
import style from "./style";
function App() {
return <Grid sx={style.myGrid}>This is a test!</Grid>;
}
export default App;
I wanna know what is the best pattern to use JSS and JSX files independently with sx
? Is it possible to get VSCode suggestions while typing sx
props in another file?