-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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] Replace forwardRef
with a shim for forward compatibility
#15955
Conversation
Deploy preview: https://deploy-preview-15955--material-ui-x.netlify.app/ |
I'm not exactly sure why |
forwardRef
with a shim for forward compatibility
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This reverts commit 4c8f9e1.
FYI @mui/x |
Should we do the same in http://github.com/mui/material-ui and https://github.com/mui/base-ui to improve performance? Or is this meant to be a temporary workaround for a regression in React 19? |
packages/x-data-grid/src/components/virtualization/GridVirtualScrollerRenderZone.tsx
Show resolved
Hide resolved
Yes, I think so 👍🏻 |
Looking a bit closer, forwardRef in React 19 looks like this: https://github.com/facebook/react/blob/7aa5dda3b3e4c2baa905a59b922ae7ec14734b24/packages/react/src/ReactForwardRef.js#L51. Almost the same as in React 18. So if this is accurate, we should revert this PR once facebook/react#31613 is fixed. Edit: OK, there is also need to factor
Don't we have tone of instances of this, e.g. |
Chances are it won't be fixed – see #15770 (comment) |
Fixes #15770
The shim asserts that Ref is always part of the render function props (even if that is not the case in older versions), this is to force typescript to warn us in case we're accidentally spreading over the ref. Refactored everything to have ref as the last prop as a result:
Ref warning doesn't work with
slotProps
though currently, as they take a slice of the props without the ref. But that can be improved as well I suppose to avoid any footguns.