makeStyles() declaration location affects css load order
See original GitHub issueThe location of makeStyles()
affects the order of css files listed in <head></head>
when using Nextjs. This causes issues when base styles override custom styles.
- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
When makeStyles()
is declared in index.tsx
, styles are properly loaded on the examples below (I added an App bar with MUI Links, not Nextjs Links). The spacing between the links and the button is incorrect in the first Codesandbox, and working properly in the second. The only change is the location of makeStyles()
. This repository is forked off of the Nextjs Typescript example.
Broken (makeStyles()
is in themes.tsx
)
Link: https://codesandbox.io/s/mystifying-bogdan-h4wq7
Demo
CSS Load order
Expected Behavior 🤔
makeStyles() should be the last css style to load. create-react-app
does not have this issue.
Not broken (makeStyles()
is in index.tsx
)
Link: https://codesandbox.io/s/distracted-framework-2o9fs
Demo
CSS Load order
Steps to Reproduce 🕹
Steps:
- Move makeStyles() declaration to the same file that uses it. See above codesandbox links.
Context 🔦
Trying to use a central styles configuration rather than having scattered css.
Your Environment 🌎
tsconfig:
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules"
]
}
Tech | Version |
---|---|
Material-UI | v4.11.0 |
React | ^16.13.1 |
Browser | FF 79 & Chrome 84 |
TypeScript | 3.9.7 |
etc. |
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
@esemeniuc We are in the process of dropping our styling engine to rely on the ones used by the community, we have stopped investment on this part one year ago, I don’t think that it’s worth covering.
Could we document this so it doesn’t cause frustration later?