Skip to content
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

[@mantine/hooks] Support ref cleanup function in React 19 with useMergedRef #7304

Merged
merged 3 commits into from
Jan 7, 2025

Conversation

elecdeer
Copy link
Contributor

fixes #7269

useMergedRef now properly handles ref callbacks that return cleanup functions in React 19.
For backward compatibility with React 18, it maintains the previous behavior of calling refs with null during unmount.

I have verified the functionality through a separate test repository, as direct testing within Mantine is not possible due to its React 18 dependency.
https://github.com/elecdeer/react-19-use-merge-ref/blob/main/react19/src/use-merged.ref.test.tsx

@rtivital
Copy link
Member

Please fix errors in tests

@elecdeer
Copy link
Contributor Author

done!

@rtivital rtivital merged commit fa0da9a into mantinedev:master Jan 7, 2025
1 check passed
@rtivital
Copy link
Member

rtivital commented Jan 7, 2025

Thanks!

@elecdeer elecdeer deleted the feat/use_merge_ref_cleanup branch January 9, 2025 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useMergedRef does not supports React 19's cleanup functions for refs
2 participants