Skip to content

fix(tooltip): accessing element.ref was removed in React 19 issue #4531

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

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/great-feet-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nextui-org/tooltip": patch
---

fix "Accessing element.ref was removed in React 19" issue (#4526)
6 changes: 5 additions & 1 deletion packages/components/tooltip/src/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ const Tooltip = forwardRef<"div", TooltipProps>((props, ref) => {
ref?: React.Ref<any>;
};

trigger = cloneElement(child, getTriggerProps(child.props, child.ref));
// Accessing the ref from props, else fallback to element.ref
// https://github.com/facebook/react/pull/28348
const childRef = child.props.ref ?? (child as any).ref;

trigger = cloneElement(child, getTriggerProps(child.props, childRef));
}
} catch (error) {
trigger = <span />;
Expand Down
Loading