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

Fix ExpansionPanel Performance Docs #18487

Closed
wants to merge 1 commit into from
Closed

Fix ExpansionPanel Performance Docs #18487

wants to merge 1 commit into from

Conversation

jameslaneconkling
Copy link

use mountOnEnter, not unmountOnExit, to prevent ExpansionPanel details from rendering before panel is expanded.

See this issue.

@mui-pr-bot
Copy link

No bundle size changes comparing 320b6f9...d4477c5

Generated by 🚫 dangerJS against d4477c5

@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 21, 2019

Thanks for the concern but mountOnEnter was made on purpose to optimize for SEO. Hopefully, the description above the demo explains it. If you see something is not coherent, please let us know.

@jameslaneconkling
Copy link
Author

@oliviertassinari This PR is just to change the docs on how to disable the SEO optimization, not on what the default behavior should be.

The current docs read:


Performance

The content of ExpansionPanels is mounted by default even if the panel is not expanded.
This default behavior has server-side rendering and SEO in mind.
If you render expensive component trees inside your panels or simply render many
panels it might be a good idea to change this default behavior by enabling the
unmountOnExit in TransitionProps:

<ExpansionPanel TransitionProps={{ unmountOnExit: true }} />

However, setting unmountOnExit will not prevent the details from mounting before expanding (as the docs suggest). Instead, mountOnEnter should be used to prevent eager rendering of content. The proposed edit to the docs for ExpansionPanel just reflects the proper way to disable the default behavior.

@oliviertassinari
Copy link
Member

@jameslaneconkling I can't observe the behavior you are describing. Do you have a reproduction?

@jameslaneconkling
Copy link
Author

@oliviertassinari damn it, can't reproduce. Must have been been doing something wrong on my end. Can confirm that TransitionProps={{ unmountOnExit: true }} is working as expected. Sorry for the confusion.

@jameslaneconkling jameslaneconkling deleted the patch-1 branch November 25, 2019 19:05
@jameslaneconkling jameslaneconkling restored the patch-1 branch November 25, 2019 19:05
@jameslaneconkling jameslaneconkling deleted the patch-1 branch November 25, 2019 19:05
@jameslaneconkling jameslaneconkling restored the patch-1 branch November 25, 2019 19:05
@oliviertassinari
Copy link
Member

Thanks for the confirmation.

@zannager zannager added the docs Improvements or additions to the documentation label Feb 10, 2023
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants