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 09cd117
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/react/src/jsx/ReactJSXElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,12 @@ 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) {
// fall back to the current owner
refOwner = ReactSharedInternals.owner;
}
ref = coerceStringRef(ref, refOwner, element.type);
}
}
owner = ReactSharedInternals.owner;
Expand Down

0 comments on commit 09cd117

Please sign in to comment.