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

[core][data grid] Fix useTimeout clear lifecycle #16031

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Dec 29, 2024

To read first: mui/material-ui#44897. Refs a guaranteed to be cleaned up until unmounted, so if they are missing, we are cleaning up too late.

So I don't think #14987's two PR fixes are correct.

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work core Infrastructure work going on behind the scenes component: data grid This is the name of the generic UI component, not the React module! labels Dec 29, 2024
@@ -1 +0,0 @@
export { default as useTimeout } from '@mui/utils/useTimeout';
Copy link
Member Author

Choose a reason for hiding this comment

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

It seems that nobody depends on this file, dead code.

@mui-bot
Copy link

mui-bot commented Dec 29, 2024

Deploy preview: https://deploy-preview-16031--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against b407d7d

Comment on lines +2 to +6
/**
* TODO, remove this file, have dependents import from:
* import useTimeout from '@mui/utils/useTimeout';
* directly.
*/
Copy link
Member Author

Choose a reason for hiding this comment

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

Only brought it back so we can quickly learn if this is correct or wrong (meaning so we can merge #16031, before mui/material-ui#44897, so we test it with a smaller userbase.

Copy link
Contributor

@romgrk romgrk left a comment

Choose a reason for hiding this comment

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

See nitpick comment in the core PR. Also I'd be fine with merging the core one before this one.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 28, 2025
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@romgrk
Copy link
Contributor

romgrk commented Jan 28, 2025

Similar issue with useOnMount in #15648, I wonder if we shouldn't instead switch useOnMount to use useEnhancedEffect.

@lauri865
Copy link
Contributor

Similar issue with useOnMount in #15648, I wonder if we shouldn't instead switch useOnMount to use useEnhancedEffect.

That can easily become a footgun though, especially under such an unassuming name. Can easily end up with a lot of render / unmount blocking code being shipped.

I would even argue that this particular case is a type error rather than a timing issue. It would be very difficult to make the same mistake in vanilla React, as a ref can indeed be null.

Copy link
Member

@cherniavskii cherniavskii left a comment

Choose a reason for hiding this comment

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

I wasn't able to reproduce #14987
But the changes make sense to me. I wasn't aware of facebook/react#19671 (comment). TIL 👍🏻

@romgrk
Copy link
Contributor

romgrk commented Jan 28, 2025

Interesting point from emotion's maintainer, having the hook be named useSynchronousEffect would be better, imho. On our side, we could also expose two versions of our hook, useOnMount and useOnMount(Synchronous|Layout). Also as I just posted on slack, I think useEnhancedEffect should have the "Layout" part in its name, "Enhanced" doesn't carry interesting information.

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! core Infrastructure work going on behind the scenes PR: out-of-date The pull request has merge conflicts and can't be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants