useMouse() returns the component's coordinates
everdrone opened this issue · 3 comments
everdrone commented
Describe the bug
useMouse
returns the component's x and y coordinates instead of the cursor positon.
To Reproduce
Steps to reproduce the behavior:
import * as React from 'react'
import useMouse from '@react-hook/mouse-position'
const Component = props => {
const ref = React.useRef(null)
const mouse = useMouse(ref, {
enterDelay: 100,
leaveDelay: 100,
})
return (
// You must provide the ref to the element you're tracking the
// mouse position of
<div ref={ref}>
Hover me and see where I am relative to the element:
<br />
x: ${mouse.x}
y: ${mouse.y}
</div>
)
}
export default function App() {
return <Component />
}
Expected behavior
Self explanatory, use the mouse position
Desktop (please complete the following information):
- OS: macOS 12.0.1
- Browser Chrome, Brave
- Version:
- react:
^17.0.2
- @react-hook/mouse-position:
^4.1.1
- react:
jaredLunde commented
Shoot thank you for this report. I know exactly where this originated and will fix promptly.
jaredLunde commented
Thank you for that report! That was a really bad one that came with a lot of consequences. Verified that this is working now here
everdrone commented
Wow this is probably the fastest fix of all time! Thank you so much!