Debian Codegraph @

web/src/components/RTLCacheProvider.jsx

raw
1 import React from "react";
2
3 import rtlPlugin from "stylis-plugin-rtl";
4 import { CacheProvider } from "@emotion/react";
5 import createCache from "@emotion/cache";
6 import { prefixer } from "stylis";
7 import { useTranslation } from "react-i18next";
8
9 // https://mui.com/material-ui/guides/right-to-left
10
11 const cacheRtl = createCache({
12 key: "muirtl",
13 stylisPlugins: [prefixer, rtlPlugin],
14 });
15
16 const RTLCacheProvider = ({ children }) => {
17 const { i18n } = useTranslation();
18
19 return i18n.dir() === "rtl" ? <CacheProvider value={cacheRtl}>{children}</CacheProvider> : children;
20 };
21
22 export default RTLCacheProvider;