import * as React from "react"; import type { PolymorphicWithRef, ButtonOwnProps } from "../types"; import { ButtonBase } from "../base-components"; import { useEventListener } from "../hooks"; import rippleEvent from "../utils/events/rippleEffect"; type ButtonProps = PolymorphicWithRef< T, ButtonOwnProps >; type ButtonElement = ( props: ButtonProps ) => React.ReactElement>; const Button: ButtonElement = React.forwardRef( ( props: ButtonProps, innerRef: typeof props.ref ) => { const { component, ...rest } = props; const buttonRef = React.useRef(null); // forwarding the ref using imperative API React.useImperativeHandle(innerRef, () => buttonRef.current); // useEventListener to add ripple effect useEventListener( "mousedown", (event) => rippleEvent(event, buttonRef), buttonRef ); return ; } ); export default Button;