-
Are transient props required to have the
Arbitrarily meaning that I have 100s of styled components that have the same structure like below but only a few actually throw the warning: const Container = styled.div<{ isSomething: boolean }>`` This issue was reported here, but I also saw it in another project and had to revert to styled components 5. We have a lot of legacy components and changing all the props to |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I believe transient props do need to start with According to the migration steps for v6, you can restore the previous behavior by wrapping your app in For example, you can do something like this to restore the behavior from v5: import isPropValid from '@emotion/is-prop-valid';
import { StyleSheetManager } from 'styled-components';
function MyApp() {
return (
<StyleSheetManager shouldForwardProp={shouldForwardProp}>
{/* other providers or your application's JSX */}
</StyleSheetManager>
)
}
// This implements the default behavior from styled-components v5
function shouldForwardProp(propName, target) {
if (typeof target === "string") {
// For HTML elements, forward the prop if it is a valid HTML attribute
return isPropValid(propName);
}
// For other elements, forward all props
return true;
} |
Beta Was this translation helpful? Give feedback.
I believe transient props do need to start with
$
.According to the migration steps for v6, you can restore the previous behavior by wrapping your app in
<StylesheetManager>
and providing an implementation forshouldForwardProp
.For example, you can do something like this to restore the behavior from v5: