mui / mui/material-ui

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

Open
#30,359 6 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

examples scope: all components
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.