use-mouse-move hook
Get Started
⚠️
Docs is under construction.
Description
This hook allows you to get the mouse position on the screen.
install
You can install the package via npm or yarn:
npm install -d @melmerrouni/custom-hooks
Example
You just need to import useMouseMove
from @melmerrouni/custom-hooks
:
demo.tsx
import {useMouseMove} from '@melmerrouni/custom-hooks';
const Target = () => {
const {position, ref} = useMouseMove();
return (
<div data-testid="target" ref={ref}>
{position && `${position.clientX}${position.clientY}`}
</div>
)
};
Demo
Move the cursor 🖱️ inside the div
Last updated on April 7, 2024