material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[core][utils] Fix useTimeout clear lifecycle

Open oliviertassinari opened this issue 1 year ago • 1 comments

As far as I know, using useOnMount() is wrong in this context. We need to clear the timeout synchronously with the component unmounts.

See https://github.com/facebook/react/issues/19671, with https://codesandbox.io/p/sandbox/unruffled-banzai-7zzr6k?file=%2Fsrc%2FDemo.tsx that illustrates the difference in behavior:

SCR-20241229-tccr

It seems the root cause of why https://github.com/mui/mui-x/issues/14987. This fix is upstream of: https://github.com/mui/mui-x/pull/16031, but it might be best to first merge downstream, so we test it with a smaller userbase.

oliviertassinari avatar Dec 29 '24 20:12 oliviertassinari

Netlify deploy preview

https://deploy-preview-44897--material-ui.netlify.app/

Bundle size report

Details of bundle changes (Toolpad) Details of bundle changes

Generated by :no_entry_sign: dangerJS against f7a1e5607b806bfc0040579615ecfc76a13c8414

mui-bot avatar Dec 29 '24 20:12 mui-bot