Skip to content
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

Cache locale dict lest child hooks always re-render #6185

Merged
merged 7 commits into from
May 16, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions packages/@react-aria/i18n/src/context.tsx
Expand Up @@ -30,10 +30,14 @@ export function I18nProvider(props: I18nProviderProps) {
let {locale, children} = props;
let defaultLocale = useDefaultLocale();

let value: Locale = locale ? {
locale,
direction: isRTL(locale) ? 'rtl' : 'ltr'
} : defaultLocale;
let value: Locale = React.useMemo(() => {
if (!locale) return defaultLocale;

return {
locale,
direction: isRTL(locale) ? 'rtl' : 'ltr'
};
}, [locale);
IgnusG marked this conversation as resolved.
Show resolved Hide resolved

return (
<I18nContext.Provider value={value}>
Expand Down