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

I18nProvider re-renders unnecessarily due to a new dict value being re-created every time #6184

Open
IgnusG opened this issue Apr 11, 2024 · 0 comments · May be fixed by #6185
Open

I18nProvider re-renders unnecessarily due to a new dict value being re-created every time #6184

IgnusG opened this issue Apr 11, 2024 · 0 comments · May be fixed by #6185

Comments

@IgnusG
Copy link

IgnusG commented Apr 11, 2024

Provide a general summary of the issue here

Some hooks like useCalendarGrid use the useLocale hook to fetch locale information. However if the I18nProvider is rendered (eg. as part of a parent update somewhere in the tree) even if locale stays the same it re-creates a new dictionary object forcing all child hooks to re-render (even if their parent components don't have to).

🤔 Expected Behavior?

The hook should memo the dict value to avoid causing renders down the tree or I18nContext should be exported to allow for custom adjustments to this behavior.

😯 Current Behavior

Only the provider is exported which causes this issue. It's not possible to access the context itself so it's not possible to resolve this problem in userland.

💁 Possible Solution

No response

🔦 Context

No response

🖥️ Steps to Reproduce

  1. Create a calendar structure as per examples wrapping it in I18nProvider somewhere close to the top of the app tree
  2. Memo the calendar component so it doesn't update when parents do
  3. Force a render to the app causing a re-render to the I18nProvider - observe the dict now changes reference causing re-renders everywhere its used (including inside the calendar - even if we don't change anything in it)

Version

3.32.1

What browsers are you seeing the problem on?

Firefox, Chrome, Safari, Microsoft Edge

If other, please specify.

No response

What operating system are you using?

macOS

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

@IgnusG IgnusG linked a pull request Apr 11, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant