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

[DataGrid] Fix potential memory leak warning #3558

Merged
merged 1 commit into from Jan 17, 2022

Conversation

m4theushw
Copy link
Member

@m4theushw m4theushw commented Jan 6, 2022

Fixes #3276

Preview: https://deploy-preview-3558--material-ui-x.netlify.app/components/data-grid/

I don't know why we never tried that. The warning is always triggered inside GridOverlay as part of GridOverlays. It turns out that GridOverlays is rendered before GridAutoSizer. That way, subscribing inside a normal effect has no risk of losing any resize event, because React executes the effects sequentially according to the tree.

{...errorProps}
{...rootProps.componentsProps?.errorOverlay}
/>
<GridAutoSizer
Copy link
Member Author

Choose a reason for hiding this comment

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

Fixes https://codesandbox.io/s/datagriddemo-material-demo-forked-49plk?file=/demo.tsx

If the error is set by the error prop, GridAutoSizer in GridBody won't render and we won't have any dimension.


let height: React.CSSProperties['height'] = viewportInnerSize?.height ?? 0;
if (rootProps.autoHeight && height === 0) {
height = 'auto';
}

if (!viewportInnerSize) {
Copy link
Member Author

Choose a reason for hiding this comment

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

To prevent misalignment when there's no dimension yet.

@m4theushw m4theushw changed the title Fix potential memory leak warning [DataGrid] Fix potential memory leak warning Jan 6, 2022
@m4theushw m4theushw added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! labels Jan 6, 2022
@m4theushw m4theushw marked this pull request as ready for review January 6, 2022 23:33
@m4theushw m4theushw self-assigned this Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DataGrid] Setting autoHeight prop or parent element style prop height causes potential memory leak
2 participants