fixed bug cache mui
This commit is contained in:
@@ -4,13 +4,25 @@ import { prefixer } from "stylis";
|
|||||||
import stylisRTLPlugin from "stylis-plugin-rtl";
|
import stylisRTLPlugin from "stylis-plugin-rtl";
|
||||||
import { CacheProvider } from "@emotion/react";
|
import { CacheProvider } from "@emotion/react";
|
||||||
|
|
||||||
const cache = createCache({
|
const isBrowser = typeof document !== 'undefined';
|
||||||
key: "mui-rtl",
|
|
||||||
stylisPlugins: [prefixer, stylisRTLPlugin],
|
const createEmotionCache = () => {
|
||||||
});
|
let insertionPoint;
|
||||||
|
|
||||||
|
if (isBrowser) {
|
||||||
|
const emotionInsertionPoint = document.querySelector('meta[name="emotion-insertion-point"]');
|
||||||
|
insertionPoint = emotionInsertionPoint ?? undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return createCache({
|
||||||
|
insertionPoint,
|
||||||
|
key: "mui-rtl",
|
||||||
|
stylisPlugins: [prefixer, stylisRTLPlugin],
|
||||||
|
});;
|
||||||
|
};
|
||||||
|
|
||||||
const cacheProviderRtl = (props) => {
|
const cacheProviderRtl = (props) => {
|
||||||
return <CacheProvider value={cache}>{props.children}</CacheProvider>;
|
return <CacheProvider value={createEmotionCache()}>{props.children}</CacheProvider>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default cacheProviderRtl;
|
export default cacheProviderRtl;
|
||||||
|
|||||||
Reference in New Issue
Block a user