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

fix: element.ref was removed in React 19 warning #4003

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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/ten-paws-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nextui-org/popover": patch
---

Fix: element.ref was removed in React 19
8 changes: 6 additions & 2 deletions packages/components/popover/src/popover-trigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ const PopoverTrigger = forwardRef<"button", PopoverTriggerProps>((props, _) => {
};
}, [children]);

// 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;

const {onPress, isDisabled, ...restProps} = useMemo(() => {
return getTriggerProps(mergeProps(otherProps, child.props), child.ref);
}, [getTriggerProps, child.props, otherProps, child.ref]);
return getTriggerProps(mergeProps(otherProps, child.props), childRef);
}, [getTriggerProps, child.props, otherProps, childRef]);

// validates if contains a NextUI Button as a child
const [, triggerChildren] = pickChildren(children, Button);
Expand Down