import { useState } from "react" ; import classnames from "classnames" ; interface Props extends React . HTMLAttributes < HTMLDivElement > { className ? : string ; onMouseDown ? : ( e : React . MouseEvent < HTMLDivElement > ) => void ; } function ClickedDiv ( props ) { const [ clicked , setClicked ] = useState ( false ) ; function handleMouseDown ( e ) { setClicked ( true ) ; if ( props . onMouseDown ) { props . onMouseDown ( e ) ; } } return ( < div { ... props } className = { classnames ( props . className , { clicked } ) } onMouseDown = { handleMouseDown } / > ) ; } export default ClickedDiv ;