[docs] Adding `prepend: true` to emotion cache breaks remix example
See original GitHub issueDuplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
Adding prepend: true
to the emotion cache used in the remix-with-typescript example to modify the injection order of mui styles and global css styles causes DOMExceptions.
Removing CssBaseline
from entry.client.tsx
will remove the DOMException, but the hydration warning remains.
Moving the style tag generator in root.tsx
also does not help to remove the hydration warning.
Expected behavior 🤔
Expected the mui styles to move from the bottom of the head
element to the top of the head
element, and the DOM to render without exceptions.
Steps to reproduce 🕹
Steps:
- Clone the https://github.com/mui-org/material-ui/blob/master/examples/remix-with-typescript/ example
- Add the prepend: true option to createCache in https://github.com/mui-org/material-ui/blob/master/examples/remix-with-typescript/app/src/createEmotionCache.ts
import createCache from '@emotion/cache';
export default function createEmotionCache() {
return createCache({ key: 'css', prepend: true });
}
- npm install, npm run dev and open in the browser
Context 🔦
Trying to reduce the precedence of mui when interoperating with other style methods (e.g. using global styles)
Your environment 🌎
`npx @mui/envinfo`
System:
OS: Linux 4.4 Ubuntu 18.04.4 LTS (Bionic Beaver)
Binaries:
Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
Yarn: 1.22.10 - /mnt/c/Program Files (x86)/Yarn/bin/yarn
npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
Browsers:
Chrome: Not Found
Firefox: Not Found
npmPackages:
@emotion/react: latest => 11.7.1
@emotion/styled: latest => 11.6.0
@mui/base: 5.0.0-alpha.61
@mui/material: latest => 5.2.5
@mui/private-theming: 5.2.3
@mui/styled-engine: 5.2.5
@mui/system: 5.2.5
@mui/types: 7.1.0
@mui/utils: 5.2.3
@types/react: latest => 17.0.37
react: latest => 17.0.2
react-dom: latest => 17.0.2
typescript: latest => 4.5.4
Browser used: Firefox
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Styling
Changes to components don't break the cache for the styles; Changes to the styles don't break ... Each route can add style links...
Read more >Server Side Rendering
If you have dynamic global styles it's advised to create cache per single render to avoid global styles from different renders leaking into...
Read more >zlj - River Thames Conditions - Environment Agency - GOV.UK
Willow run high school basketball, Bra size range, Rada puchaczy remix. ... Dessin encre chine, Std map insert reference, Screen calibration test, ...
Read more >Untitled
What is a node in xml document, Eels concert review 2013! ... Joy to live, Skinstore clarisonic genuine, Taekwondo belt holder uk, Egg...
Read more >SpecialReleases
40 Break Datz Real Gangsta Deep Down Dead Man Walking 781 Redrum ... A picture disc version of Ace's 2020 covers album, insert...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ShuPink there is definitely some issue with the Remix example, e. g. https://github.com/mui/material-ui/issues/31957. I will need to dive deeper before I can share any update.
@mnajdova I’m not sure why I can’t see your reply here… so I guess I’ll just look like I’m talking to myself 😅 .
Sorry for not being very clear, I was trying to make my global/shared styles take precedence over mui’s because mui’s styles would override them. Hopefully this picture might make it clearer: green = global css file, and blue = mui styles.
global css file being overridden by mui
document head element style tag order
Um, but I actually managed to get the
prepend: true
option working with the emotion cache as expected by removing the block that you mentioned: https://github.com/mui-org/material-ui/blob/master/examples/remix-with-typescript/app/root.tsx#L25, so I’ll close the issue.Thanks very much for your time, apologies for the muck about.