React version: 17
Steps To Reproduce
- Hover the button
- Note the double log produced
Link to code example: https://codesandbox.io/s/react-mouseenter-bug-uyswr?file=/src/App.js
The current behavior
The onMouseEnter is triggered twice.
The expected behavior
The onMouseEnter should be triggered only once.
A few more notes:
- I've tested on React 16.14 and it seems that bug only appeared in 17. (I can see it in the first ever 17 rc as well).
- It's specifically when something happens to be portalled on the page too (you'll see if you don't render in a portal, no issue)
- It is also linked to the fact there's space around the target that gets moused over. You'll notice that if you comment out the heading below for example and you mouse-enter coming from the bottom, the bug won't be there. But it will be at the top. Similarly if we you keep the headings rendered, but override their margins to be 0 such that there's no gap between the heading and the button, it won't happen either.
I'm conscious this is all really odd but I haven't been able to find out exactly what's happening here…
React version: 17
Steps To Reproduce
Link to code example: https://codesandbox.io/s/react-mouseenter-bug-uyswr?file=/src/App.js
The current behavior
The
onMouseEnteris triggered twice.The expected behavior
The
onMouseEntershould be triggered only once.A few more notes:
I'm conscious this is all really odd but I haven't been able to find out exactly what's happening here…