From 1c209801a9a8eb65d1eeb3346aadccac8793148f Mon Sep 17 00:00:00 2001 From: siriwatknp Date: Wed, 1 May 2024 08:47:32 +0700 Subject: [PATCH] check if component is not html --- packages/pigment-css-react/src/styled.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/pigment-css-react/src/styled.js b/packages/pigment-css-react/src/styled.js index 8ec2edf2..e4a18631 100644 --- a/packages/pigment-css-react/src/styled.js +++ b/packages/pigment-css-react/src/styled.js @@ -123,14 +123,14 @@ export default function styled(tag, componentMeta = {}) { getVariantClasses(inProps, variants), ); - if (shouldUseAs && !shouldForwardProp) { - // Reassign `shouldForwardProp` based on the incoming `as` prop - if (isHtmlTag(Component)) { - finalShouldForwardProp = isPropValid; - } else if (slot === 'Root' || slot === 'root') { - finalShouldForwardProp = rootShouldForwardProp; - } else { - finalShouldForwardProp = slotShouldForwardProp; + if (inProps.as && !shouldForwardProp) { + // Reassign `shouldForwardProp` if incoming `as` prop is a React component + if (!isHtmlTag(Component)) { + if (slot === 'Root' || slot === 'root') { + finalShouldForwardProp = rootShouldForwardProp; + } else { + finalShouldForwardProp = slotShouldForwardProp; + } } }