trevorsg, you need to pass the button properties:
import * as React from 'react'
type ButtonProps = React.HTMLProps<HTMLButtonElement>
const FancyButton = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => (
<button type="button" ref={ref} className="FancyButton">
{props.children}
</button>
))
// You can now get a ref directly to the DOM button:
const ref = React.createRef<HTMLButtonElement>()
<FancyButton ref={ref}>Click me!</FancyButton>
ADDED:
In recent versions of TS and @types/react, you can also use React.ComponentPropsWithoutRef<'button'>
instead of React.HTMLProps<HTMLButtonElement>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…