Created
February 5, 2023 15:25
-
-
Save Lahirutech/c3036c4bd2c63a801116817b34322b41 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import createCache from '@emotion/cache'; | |
const isBrowser = typeof document !== 'undefined'; | |
// On the client side, Create a meta tag at the top of the <head> and set it as insertionPoint. | |
// This assures that MUI styles are loaded first. | |
// It allows developers to easily override MUI styles with other styling solutions, like CSS modules. | |
export default function createEmotionCache() { | |
let insertionPoint; | |
if (isBrowser) { | |
const emotionInsertionPoint = document.querySelector<HTMLMetaElement>( | |
'meta[name="emotion-insertion-point"]' | |
); | |
insertionPoint = emotionInsertionPoint ?? undefined; | |
} | |
return createCache({ key: 'mui-style', insertionPoint }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment