use-gesture: useHover doesn't fire when component is mounted
The useHover
hook is not fired when the component is first mounted, and a mouse is within the components bounds.
CodeSandbox: https://codesandbox.io/s/charming-forest-f1cjv
I know this might be a little bit of a challenge, and I’m happy to make a PR if required 😄
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (2 by maintainers)
I’m not sure why, but using
target
with a ref instead of spreadingbind
fixes this issue for me.Overkill in the sense that the current mouse move listener does some calculations about the mouse movement under the hood (velocity, distance) which are not needed for the purpose of just hovering, I’ll see how to find the leanest way to achieve this.
You’re right, using hover as the action is confusing. It’s a CSS selector and from that perspective it should behave like it.
Since there’s a
domTarget
option, nothing would prevent the lib to check for the hover selector on the ref when that option is used. I just need to see how hacky this might be.I’ll reopen the issue so that I can keep track of it. Thanks for the suggestion!