I'm using the react-bootstrap package, in React, and written in TypeScript.
I have a component that wraps the Button component from react-bootstrap, and I want to accept all props that Button accepts (and therefore, that the underlying HTML button element also accepts, like style), to this new component, so that I can pass them down to Button.
Simple example, with no types specified yet:
import { Button } from 'react-bootstrap';
function WrapperButton(props) {
const { children } = props;
return <Button {...props}>{children}</Button>;
}
In react-bootstrap/Button.d.ts, <Button> is declared with:
declare class Button<
As extends React.ElementType = 'button'
> extends BsPrefixComponent<As, ButtonProps> {}
But if I set props: BsPrefixComponent<'button', ButtonProps> then it doesn't accept attributes like style and children.
Is there a more appropriate type I could use, for this scenario?