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

[docs] Avoid re-mounting the whole tree when switching theme direction #28495

Merged
merged 1 commit into from Sep 22, 2021

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Sep 20, 2021

Switching between right-to-left and left-to-right currently re-mounts the whole tree since we inject an additional CacheProvider for right-to-left. It's unclear why. Instead, we use a single CacheProvider and just pass a different value.

This also helps identifying where a cache is coming from.

@eps1lon eps1lon added docs Improvements or additions to the documentation performance labels Sep 20, 2021

return (
<StyleSheetManager stylisPlugins={rtl ? [rtlPluginSc] : []}>
<Wrapper {...wraperProps}>{props.children}</Wrapper>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing Wrapper meant that all children will get re-mounted. Especially high up in React trees, changing parent element types should be avoided at all cost.

@mui-pr-bot
Copy link

mui-pr-bot commented Sep 20, 2021

No bundle size changes

Generated by 🚫 dangerJS against fac1bec

Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, makes sense

@mnajdova mnajdova merged commit 7c95627 into mui:master Sep 22, 2021
@eps1lon eps1lon deleted the docs/remount-cache branch September 22, 2021 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants