Skip to content

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

Open
@ShuPink

Description

@ShuPink

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

Metadata

Metadata

Assignees

Labels

examplesRelating to /examples

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions