[core][utils] Fix useTimeout clear lifecycle
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:
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.
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