Skip to content

Commit

Permalink
add a failing test case for .attrs()
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonNiklasson committed May 14, 2024
1 parent 770d1fa commit e2b8b04
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/styled-components/src/test/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -527,3 +527,23 @@ class ParentClassComponent1 extends React.Component<{ $prop1?: boolean }> {}
const ParentClassComponent2 = styled(ParentClassComponent1)<{ $prop2?: boolean }>``;

<ParentClassComponent2 $prop1={true} $prop2={true} />;

{
// React.forwardRef in combination with .attrs()

const Button = React.forwardRef<
HTMLButtonElement,
{
icon: 'a' | 'b' | 'c';
}
>((props, ref) => {
return (
<button ref={ref} {...props}>
button
</button>
);
});
const ButtonWithIcon = styled(Button).attrs({ icon: 'a' })``;

<ButtonWithIcon />;
}

0 comments on commit e2b8b04

Please sign in to comment.