Skip to content

Commit 92a2ab1

Browse files
authored
fix by removing sc as propr types
1 parent 72b6eba commit 92a2ab1

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/Button/Button.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import React, {forwardRef} from 'react'
2-
import {ForwardRefComponent as PolymorphicForwardRefComponent} from '@radix-ui/react-polymorphic'
32
import {ButtonProps} from './types'
43
import {ButtonBase} from './ButtonBase'
54

6-
const ButtonComponent = forwardRef(
7-
({children, as: As = 'button', ...props}, forwardedRef): JSX.Element => {
5+
const ButtonComponent = forwardRef<HTMLButtonElement, ButtonProps>(
6+
({children, ...props}, forwardedRef): JSX.Element => {
87
return (
9-
<ButtonBase ref={forwardedRef} as={As} {...props}>
8+
<ButtonBase ref={forwardedRef} as="button" {...props}>
109
{children}
1110
</ButtonBase>
1211
)
1312
}
14-
) as PolymorphicForwardRefComponent<'button' | 'a', ButtonProps>
13+
)
1514

1615
ButtonComponent.displayName = 'Button'
1716

src/Button/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ export type VariantType = 'default' | 'primary' | 'invisible' | 'danger' | 'outl
1313

1414
export type Size = 'small' | 'medium' | 'large'
1515

16-
type StyledButtonProps = ComponentPropsWithRef<typeof StyledButton>
16+
/**
17+
* Remove styled-components polymorphic as prop, which conflicts with radix's
18+
*/
19+
type StyledButtonProps = Omit<ComponentPropsWithRef<typeof StyledButton>, 'as'>
1720

1821
type ButtonA11yProps = {'aria-label': string; 'aria-labelby'?: never} | {'aria-label'?: never; 'aria-labelby': string}
1922

0 commit comments

Comments
 (0)