question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[docs] Adding `prepend: true` to emotion cache breaks remix example

See original GitHub issue

Duplicates

  • 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.

remix-prepend

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:

  1. Clone the https://github.com/mui-org/material-ui/blob/master/examples/remix-with-typescript/ example
  2. 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 });
}
  1. 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:open
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
mnajdovacommented, Jun 1, 2022

@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.

1reaction
ShuPinkcommented, Dec 23, 2021

@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 remix-style

document head element style tag order remix-head-mu

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found