Pattern for Reusable Button Wrapper #7511
-
I am attempting to create a Reusable Button component for our Design System, and I am running into an issue, I have seen this with some other components as well, but basically, I want to be able to to do this. import { Button, ButtonProps } from 'react-aria-components'
const ReusableButton = ({ children, ...props }: ButtonProps) => {
return (
<Button {...props}>
{children}
<Icon />
</Button>
);
}; This results in Typescript errors for
Both The only way to get around this is to extend |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
We extend ButtonProps from RAC, but we omit children from it and change it to what we actually expose |
Beta Was this translation helpful? Give feedback.
We extend ButtonProps from RAC, but we omit children from it and change it to what we actually expose
https://github.com/adobe/react-spectrum/blob/main/packages/%40react-spectrum/s2/src/Button.tsx#L54