From 37e6733fe7ac7b27208fe2b5e32745f98746533f Mon Sep 17 00:00:00 2001 From: p-sw Date: Sun, 26 May 2024 20:01:09 +0900 Subject: [PATCH] fix: remove asChild from prop propagation in Slot --- packages/react/shared.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/react/shared.tsx b/packages/react/shared.tsx index 8d295b8..37ee8e2 100644 --- a/packages/react/shared.tsx +++ b/packages/react/shared.tsx @@ -321,11 +321,13 @@ interface SlotProps { export const Slot = React.forwardRef>( (props, ref) => { const { children, ...slotProps } = props; + const { asChild: _1, ...safeSlotProps } = slotProps; if (!React.isValidElement(children)) { + console.warn(`given children "${children}" is not valid for asChild`); return null; } return React.cloneElement(children, { - ...mergeReactProps(slotProps, children.props), + ...mergeReactProps(safeSlotProps, children.props), ref: combinedRef([ref, (children as any).ref]), } as any); }