-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
React 19 element.ref access warning in ComboboxEventsTarget
#7028
Comments
Note that this is also happening for popovers:
|
Also occurring for the |
found this in discussions https://github.com/orgs/mantinedev/discussions/6323 i assum it's not advisable yet to upgrade to react 19? |
React 19 has not been released yet, the latest available version of react on npm is 18.3.1. If you want to use experimental features, you can expect issues like this. Once React 19 is out, these issues will be resolved in patch versions. |
@rtivital, I wish Vercel would share your opinion... 😊 If you're using the App Router in Next.js 15, which is now GA, they're forcing React 19 RC no matter what you're specifying in your That being said, I may be wrong, but I think this would be quite easy to fix and a quick-win. Going through the codebase I've discovered just 4 places that trigger this error: mantine/packages/@mantine/core/src/components/Combobox/ComboboxEventsTarget/ComboboxEventsTarget.tsx Line 79 in fbcee92
mantine/packages/@mantine/core/src/components/Popover/PopoverTarget/PopoverTarget.tsx Line 44 in fbcee92
mantine/packages/@mantine/core/src/components/Tooltip/TooltipFloating/TooltipFloating.tsx Line 106 in fbcee92
A quick, non-invasive way to have this fixed in the next patch version would be to simply replace Please let me know your thoughts. |
|
Like I said, if you're on Next.js 15 with the app router, it will always use its internally packaged React 19, no matter what you Notice how the component inspector mentions "rendered by AFAIK, there's simply no way to make it use React 18. Which basically means anyone starting a new app with Next.js + Mantine will eventually bump into these issues. It's just a matter of days till this will start to generate a lot of community pressure; I know what it means and I find it kind of frustrating too, because I'm also struggling to maintain Mantine DataTable and ContextMenu in my own spare time 😮💨 |
…p usage in Tooltip, Popover and Combobox components (#7028)
As I predicted, the above approach does not work for React 18.3, it shows error. Instead, I've created a function that is now exported from import React from 'react';
export function getRefProp(element: any) {
const version = React.version;
if (typeof React.version !== 'string') {
return (element as any)?.ref;
}
if (version.startsWith('18.')) {
return (element as any)?.ref;
}
return (element as any)?.props?.ref;
} |
Fixed in 7.13.5 |
Dependencies check up
What version of @mantine/* packages do you have in package.json?
^7.13.4
What package has an issue?
@mantine/core
What framework do you use?
Next.js
In which browsers you can reproduce the issue?
Not applicable – issue is not related to the browser
Describe the bug
I get the following error in my console:
Call Stack
And also the following:
Call Stack
Interestingly enough, using the same component in a modal (that is opened manually) doesn't cause any issues.
But if the same form is part of a page directly these errors pop up.
Let me know if you need any more info/code.
If possible, include a link to a codesandbox with a minimal reproduction
I'm pretty sure this happens on all React 19 builds, hence I don't think there's a need for a sandbox.
But, I can make one if necessary.
Possible fix
I'm not an expert, but I think I see what the fix would be.
I did a google-fu, and found this:
material-ui commit (Scroll to the bottom)
Perhaps the same fix could be implemented here? (I assume this is the line causing the issue?)
mantine/packages/@mantine/core/src/components/Combobox/ComboboxEventsTarget/ComboboxEventsTarget.tsx
Line 79 in fbcee92
I'm willing to fix this issue with some guidance.
Thank you!
Self-service
The text was updated successfully, but these errors were encountered: