You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In React 18, ref functions were called with null when unmounting a component.
However, In React 19, a cleanup function is called at unmount time if ref returns a cleanup function, similar to how useEffect cleanup works.
The useMergedRef utility in Mantine currently does not handle these cleanup functions properly.
If possible, include a link to a codesandbox with a minimal reproduction
No response
Possible fix
No response
Self-service
I would be willing to implement a fix for this issue
The text was updated successfully, but these errors were encountered:
Sorry, there were more considerations than I initially thought, and I haven't finished it yet.
We need to ensure it works with both React 18 and React 19, and that the behavior is not broken when merging CallbackRefs with cleanup function and those without.
Dependencies check up
What version of @mantine/* packages do you have in package.json?
7.15.1
What package has an issue?
@mantine/hooks
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
React 19 supports cleanup functions for
ref
callbacks.https://react.dev/blog/2024/12/05/react-19#cleanup-functions-for-refs
In React 18,
ref
functions were called withnull
when unmounting a component.However, In React 19, a cleanup function is called at unmount time if
ref
returns a cleanup function, similar to how useEffect cleanup works.The
useMergedRef
utility in Mantine currently does not handle these cleanup functions properly.If possible, include a link to a codesandbox with a minimal reproduction
No response
Possible fix
No response
Self-service
The text was updated successfully, but these errors were encountered: