Skip to content

Commit

Permalink
Fix cloneElement using string ref w no owner
Browse files Browse the repository at this point in the history
  • Loading branch information
josephsavona committed Apr 9, 2024
1 parent 7f93cb4 commit da05c44
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/react/src/jsx/ReactJSXElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,11 @@ export function cloneElement(element, config, children) {
// Silently steal the ref from the parent.
ref = config.ref;
if (!disableStringRefs) {
ref = coerceStringRef(ref, owner, element.type);
let refOwner = owner;
if (refOwner == null) {
refOwner = ReactSharedInternals.owner;
}
ref = coerceStringRef(ref, refOwner, element.type);
}
}
owner = ReactSharedInternals.owner;
Expand Down

0 comments on commit da05c44

Please sign in to comment.