import React, { useEffect, useState } from "react";
const useMouseButton: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("mousemove",updateMouse)
return()=> (
document.removeEventListener("mousemove",updateMouse)
)
},[])
return (
<p>x:{positions.x},Y:{positions.y}</p>
)
};
export default useMouseButton;