import React, { useEffect, useState } from "react";
interface IHelloProps {
message?: string;
}
const MouseButton:React.FC = () => {
const [like, setLike] = useState(0);
const [positions,setPosition]=useState({x:0,y:0})
useEffect(()=>{
const updateMouse=(e:MouseEvent)=>{
setPosition({x:e.clientX,y:e.clientY})
}
document.addEventListener("click",updateMouse)
return()=> (
document.removeEventListener("click",updateMouse)
)
})
return (
<p>x:{positions.x},Y:{positions.y}</p>
)
};
export default MouseButton;