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
I have verified that I use latest version of all @mantine/* packages
What version of @mantine/* packages do you have in package.json?
8.0.0
What package has an issue?
@mantine/hooks
What framework do you use?
Vite
In which browsers you can reproduce the issue?
All
Describe the bug
While exploring the codebase with the intention of using the martine package, I came across the implementation of useCallbackRef, and I believe there are a couple of opportunities for improvement.
Currently, the callback reference is being updated on every render, regardless of whether the callback itself has changed. It would be more efficient to include the callback in the dependency array so that the ref only updates when the actual reference changes.
Also, I think it makes more sense to use useCallback rather than useMemo for memoizing the returned function. While both approaches work functionally, useCallback better conveys the intent since the return value is a function, and this aligns more clearly with the semantics of a "callback ref" from a consumer's perspective.
If this change is acceptable, I'm happy to work on a PR and include corresponding test cases as well.
If possible, include a link to a codesandbox with a minimal reproduction
This discussion was converted from issue #7823 on May 12, 2025 09:12.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Dependencies check up
What version of @mantine/* packages do you have in package.json?
8.0.0
What package has an issue?
@mantine/hooks
What framework do you use?
Vite
In which browsers you can reproduce the issue?
All
Describe the bug
While exploring the codebase with the intention of using the martine package, I came across the implementation of useCallbackRef, and I believe there are a couple of opportunities for improvement.
Currently, the callback reference is being updated on every render, regardless of whether the callback itself has changed. It would be more efficient to include the callback in the dependency array so that the ref only updates when the actual reference changes.
Also, I think it makes more sense to use useCallback rather than useMemo for memoizing the returned function. While both approaches work functionally, useCallback better conveys the intent since the return value is a function, and this aligns more clearly with the semantics of a "callback ref" from a consumer's perspective.
If this change is acceptable, I'm happy to work on a PR and include corresponding test cases as well.
If possible, include a link to a codesandbox with a minimal reproduction
No response
Possible fix
Self-service
Beta Was this translation helpful? Give feedback.
All reactions