-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[docs] Inform about specific files for DataGrid locales #30411
Conversation
fb19438
to
a78d36f
Compare
Another way would be to fix the line you've provided and handle cases when -theme={(outerTheme) => createTheme(outerTheme, locales[locale])}
+theme={(outerTheme) => createTheme(outerTheme ?? {}, locales[locale])} |
@mnajdova I do not manage to make your solution works because JS does not enter in the function. From what I understand, the bug occurs in emotion which is looking for the outerTheme because the theme is a function. I found the following solution to make it works both in CodeSandbox and the doc const theme = useTheme();
const themeWithLocale = createTheme(theme, locales[locale]); https://codesandbox.io/s/locales-material-demo-forked-0yj0w?file=/demo.tsx But I'm not sure it is a good practice to show in the documentation |
import * as locales from '@mui/material/locale'; | ||
|
||
export default function Locales() { | ||
const [locale, setLocale] = React.useState('zhCN'); | ||
|
||
const theme = useTheme(); | ||
const themeWithLocale = createTheme(theme, locales[locale]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better, let's just memo this and change it only if the locale
changes.
To test the new demo and check codeSandbox works: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM
Fix mui/mui-x#3514
It is not clear that when using the DataGrid component locales must be imported from the DataGrid package.
Also the codesandbox did not work because the following line is using
outerTheme
to know if the documentation is in light or dark mode.But the codeSandbox, does not declareanother them, so
outerTheme
is not defined, leading to a bug.I removed the demo toolbar because there is an example on top of the demo