-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[pickers] Do not loose the translations when using nested LocalizationProvider
with each a localeText
prop
#6895
[pickers] Do not loose the translations when using nested LocalizationProvider
with each a localeText
prop
#6895
Conversation
LocalizationProvider
translations behaviors
@@ -56,10 +56,15 @@ export function LocalizationProvider<TDate>(inProps: LocalizationProviderProps<T | |||
MuiPickersAdapterContext, | |||
) ?? { utils: undefined, localeText: undefined }; | |||
|
|||
const tempLocaleText = React.useMemo( |
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.
Otherwise when inProps.localeText
is not undefined, we loose the parent one.
These are the results for the performance tests:
|
LocalizationProvider
translations behaviorsLocalizationProvider
with each a localeText
prop
const localeText = React.useMemo( | ||
() => ({ ...props.localeText, ...parentLocaleText, ...inLocaleText }), | ||
[props.localeText, parentLocaleText, inLocaleText], | ||
); |
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.
props.localeText
is not obvious to get
What about moving this after props
destructuring to be able to write
() => ({ ...defaultizedLocaleText, ...parentLocaleText, ...inLocaleText }),
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.
OK for me, I'll just rename defaultizedLocaleText
into themeLocaleText
to make clear that it can only contain the theme value and never the value from the inProps
No description provided.