useMouse
Aboutβ
Mouse position hook for React.
Installationβ
npm install --save rooks
Importing the hookβ
import { useMouse } from 'rooks';
Usageβ
function Demo() {
const { x, y } = useMouse();
return (
<>
<p> Move mouse here to see changes to position </p>
<p>X position is {x || 'null'}</p>
<p>X position is {y || 'null'}</p>
</>
);
}
render(<Demo />);
Returned Objectβ
Returned object attributes | Type | Description |
---|---|---|
x | int | X position of mouse |
y | int | Y position of mouse |
Codesandbox Examplesβ
Basic Usageβ
Join Bhargav's discord serverβ
You can click on the floating discord icon at the bottom right of the screen and talk to us in our server.