Skip to content

Commit

Permalink
[docs] Document how to unmount transition child (#30382)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari authored Dec 24, 2021
1 parent 31924ee commit 83b7ea0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/src/modules/components/AppLayoutDocsFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export default function AppLayoutDocsFooter() {
</PaginationDiv>
</React.Fragment>
)}
<Collapse in={commentOpen} onEntered={handleEntered}>
<Collapse in={commentOpen} unmountOnExit onEntered={handleEntered}>
<form
aria-labelledby="feedback-message"
onReset={handleCancelComment}
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/components/accordion/accordion.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ accordions it might be a good idea to change this default behavior by enabling t
<Accordion TransitionProps={{ unmountOnExit: true }} />
```

As with any performance optimization this is not a silver bullet. Be sure to identify
bottlenecks first and then try out these optimization strategies.
As with any performance optimization this is not a silver bullet.
Be sure to identify bottlenecks first and then try out these optimization strategies.

## Accessibility

Expand Down
14 changes: 14 additions & 0 deletions docs/src/pages/components/transitions/transitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,17 @@ You can also visit the dedicated sections of some of the components:
- [Popper](/components/popper/#transitions)
- [Snackbar](/components/snackbars/#transitions)
- [Tooltip](/components/tooltips/#transitions)

## Performance & SEO

The content of transition component is mounted by default even if `in={false}`.
This default behavior has server-side rendering and SEO in mind.
If you render expensive component trees inside your transition it might be a good idea to change this default behavior by enabling the
`unmountOnExit` prop:

```jsx
<Fade in={false} unmountOnExit />
```

As with any performance optimization this is not a silver bullet.
Be sure to identify bottlenecks first and then try out these optimization strategies.

0 comments on commit 83b7ea0

Please sign in to comment.