Spread props for a react component
You can declare WalletProps
as React.SVGProps<SVGSVGElement>
, so that it will contain all the attributes of an SVG element. There is then no longer any need to destructure props
:
type WalletProps = React.SVGProps<SVGSVGElement>;
const Wallet: React.FC<WalletProps> = (props) => {
return (
<svg
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"
{...props}
>
...
</svg>
)
}
In the event that you have other props to merge into it, e.g. foo
and bar
, then it is a matter of creating a union type:
type WalletProps = React.SVGProps<SVGSVGElement> & { foo: FooType, bar: BarType };