diff --git a/.changeset/great-feet-lay.md b/.changeset/great-feet-lay.md new file mode 100644 index 0000000000..a76e81d991 --- /dev/null +++ b/.changeset/great-feet-lay.md @@ -0,0 +1,5 @@ +--- +"@nextui-org/tooltip": patch +--- + +fix "Accessing element.ref was removed in React 19" issue (#4526) diff --git a/packages/components/tooltip/src/tooltip.tsx b/packages/components/tooltip/src/tooltip.tsx index e014eb8944..feda666bca 100644 --- a/packages/components/tooltip/src/tooltip.tsx +++ b/packages/components/tooltip/src/tooltip.tsx @@ -48,7 +48,11 @@ const Tooltip = forwardRef<"div", TooltipProps>((props, ref) => { ref?: React.Ref; }; - 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 = ;