From f747d9d83ceaa2505043eed82717647b9a642e8d Mon Sep 17 00:00:00 2001 From: Hiogo de Pariz Cavalheiro Date: Wed, 2 Aug 2023 11:30:47 -0300 Subject: [PATCH] fix: react warning on props --- src/styled.tsx | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/styled.tsx b/src/styled.tsx index f2f2243..695c764 100644 --- a/src/styled.tsx +++ b/src/styled.tsx @@ -15,29 +15,29 @@ export const styled: W.Styled = function( defaultVariants, } ) { - const overrideVariantProps = variants - ? Object.fromEntries(Object.keys(variants).map(key => [key, undefined])) - : {}; - const overrideTransientProps = - transient && variants - ? Object.fromEntries( - Object.keys(variants) - .filter(key => transient.includes(key)) - .map(key => [key, undefined]) - ) - : {}; const Component = ( { as: asProp, ...props }: W.StyledProps, ref: any ): ReactElement => { const Tag = (asProp || component) as ElementType; const isTag = typeof component === 'string'; + const _props = {...props} + + // remove all variants props if the component is a tag name + if(isTag) { + if(variants) { + Object.keys(variants).forEach(key => delete _props[key]) + } + } else { + if(variants && transient) { + Object.keys(variants).filter(key => transient.includes(key)).forEach(key => delete _props[key]) + } + } + return (