-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I set window
with useMouse()
?
#203
Comments
you can but maybe the type is incorrect. would happily accept a PR that fixes it. |
I think the type is not the only thing to be fixed. Like we cannot use window obj in SSR? ( I’m a beginner so it might be wrong tho🙇) |
Using const mouse = useMouse(window as any); fails. Typescript works fine, but there is a runtime stack trace.
This is using the latest version of this library in the newest version of Chrome with recent react 18. |
My guess is that the solution to this issue is:
const mouse = useMouse(document.body); which I think does work as one would expect with the window. This is the case of an |
So the types are correct |
Sorry for creating an issue that is not a bug report or feature request.
How do i set
window
as a target ofuseMouse()
?As I read the README, it looks like I can do that, but I couldn't find the way to do so.
react-hook/packages/mouse-position/README.md
Line 74 in 6c07641
The text was updated successfully, but these errors were encountered: