A light npm package to track mouse position
npm install react-use-mouse-position- A lightweight (508 B) package to easily track mouse position in Reactjs
- Very useful for tinder style cards and other draggable elements
- v1.0.2 adds a variety of touch events, improving mobile usability
npm install react-use-mouse-position
``js
import React from "react";
import { useMousePosition } from "react-use-mouse-position";
function MyApp() {
const { mouseX, mouseY } = useMousePosition();
console.log("mouseX:", mouseX);
}
`
| Name | Type | Default | Description |
| ------ | ----- | ------- | ----------------------------- |
| mouseX | num | | The mouses current x position |num` | | The mouses current y position |
| mouseY |
Code released under the MIT license.