I just can't wrap my head around this I guess, I've tried probably half a dozen times and always resort to any... Is there a legitimate way to start with an HTML element, wrap that in a component, and wrap that in another component such that the HTML props pass through everything? Essentially customizing the HTML element? For example, something like:
interface MyButtonProps extends React.HTMLProps<HTMLButtonElement> {}
class MyButton extends React.Component<MyButtonProps, {}> {
render() {
return <button/>;
}
}
interface MyAwesomeButtonProps extends MyButtonProps {}
class MyAwesomeButton extends React.Component<MyAwesomeButtonProps, {}> {
render() {
return <MyButton/>;
}
}
Usage:
<MyAwesomeButton onClick={...}/>
Whenever I attempt this sort of composition, I get an error similar to:
Property 'ref' of foo is not assignable to target property.
tsccommand and works fine. I tried to render<MyAwesomeButton onClick={() => console.log('Clicked')}/><button {...this.props} />exactly?React.ComponentsProps<"button">the generic input can be anything from a react component to a string such as "div". There are also the variantsComponentsPropsWithRefandComponentsPropsWithoutRefto use when working with or without ref forwarding.