From dcbad53d3900ddeda6dcb22cc764890ed630a022 Mon Sep 17 00:00:00 2001 From: p-sw Date: Tue, 28 May 2024 22:15:39 +0900 Subject: [PATCH] refactor: extract asChild in otherProps of Button --- packages/react/components/Button.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/react/components/Button.tsx b/packages/react/components/Button.tsx index 7815c00..ec5f5e4 100644 --- a/packages/react/components/Button.tsx +++ b/packages/react/components/Button.tsx @@ -107,11 +107,12 @@ export interface ButtonProps const Button = React.forwardRef( (props, ref) => { - const [variantProps, otherProps] = resolveVariants(props); + const [variantProps, otherPropsCompressed] = resolveVariants(props); + const { asChild, ...otherPropsExtracted } = otherPropsCompressed; - const Comp = otherProps.asChild ? Slot : "button"; + const Comp = asChild ? Slot : "button"; const compProps = { - ...otherProps, + ...otherPropsExtracted, className: buttonVariants(variantProps), };