I'm creating a custom component in React, and I need to export it using forwardedRef. But when I try, this error occurs:
my code:
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>{ ref?: React.RefObject<HTMLButtonElement>;}class Button extends React.Component<ButtonProps> { render() { const { ref, children, ...otherProps } = this.props; return (<button {...otherProps} ref={ref}> {children}</button> ) }}const ButtonForwarded = React.forwardRef<ButtonProps>((props, ref) => <Button {...props} ref={ref} /> );ButtonForwarded.displayName = 'Button';export default ButtonForwarded;