forked from vercel/ai-chatbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: @radix-ui/react-slot with React 19
- Loading branch information
Showing
3 changed files
with
64 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,8 @@ | |
"use-sync-external-store": "1.4.0" | ||
}, | ||
"patchedDependencies": { | ||
"@radix-ui/[email protected]": "patches/@[email protected]" | ||
"@radix-ui/[email protected]": "patches/@[email protected]", | ||
"@radix-ui/react-slot": "patches/@radix-ui__react-slot.patch" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
diff --git a/dist/index.js b/dist/index.js | ||
index 724cd6fcdf2dce8622bcef6a4880e92fe05cf44c..c335e011edad42951d0c67439debe27a6a7688aa 100644 | ||
--- a/dist/index.js | ||
+++ b/dist/index.js | ||
@@ -63,11 +63,15 @@ var SlotClone = React.forwardRef((props, forwardedRef) => { | ||
const { children, ...slotProps } = props; | ||
if (React.isValidElement(children)) { | ||
const childrenRef = getElementRef(children); | ||
- return React.cloneElement(children, { | ||
- ...mergeProps(slotProps, children.props), | ||
- // @ts-ignore | ||
- ref: forwardedRef ? (0, import_react_compose_refs.composeRefs)(forwardedRef, childrenRef) : childrenRef | ||
- }); | ||
+ const props = { | ||
+ ...mergeProps(slotProps, children.props) | ||
+ } | ||
+ // do not pass ref to React.Fragment for React 19 compatibility | ||
+ if (children.type !== React.Fragment) { | ||
+ props.ref = forwardedRef ? (0, import_react_compose_refs.composeRefs)(forwardedRef, childrenRef) : childrenRef; | ||
+ } | ||
+ | ||
+ return React.cloneElement(children, props); | ||
} | ||
return React.Children.count(children) > 1 ? React.Children.only(null) : null; | ||
}); | ||
diff --git a/dist/index.mjs b/dist/index.mjs | ||
index 73e28afb741e05e1d1bb4206fa917918bb9457ec..61b961dae21928d73c2a543d4e463e144846a29f 100644 | ||
--- a/dist/index.mjs | ||
+++ b/dist/index.mjs | ||
@@ -25,11 +25,15 @@ var SlotClone = React.forwardRef((props, forwardedRef) => { | ||
const { children, ...slotProps } = props; | ||
if (React.isValidElement(children)) { | ||
const childrenRef = getElementRef(children); | ||
- return React.cloneElement(children, { | ||
- ...mergeProps(slotProps, children.props), | ||
- // @ts-ignore | ||
- ref: forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef | ||
- }); | ||
+ const props = { | ||
+ ...mergeProps(slotProps, children.props) | ||
+ } | ||
+ // do not pass ref to React.Fragment for React 19 compatibility | ||
+ if (children.type !== React.Fragment) { | ||
+ props.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef; | ||
+ } | ||
+ | ||
+ return React.cloneElement(children, props); | ||
} | ||
return React.Children.count(children) > 1 ? React.Children.only(null) : null; | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.