-
Notifications
You must be signed in to change notification settings - Fork 47.1k
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
In React 16, onMouseEnter is triggered an extra time when entering a new child #10906
Comments
@Sherryer Do you mean you want the click button to be free from the |
I can confirm I see the difference between 15 and 16 behavior. Maybe a bug. |
(On the side note, how awesome is it that we speak different languages, and yet can understand each other with code? 😄 ) |
@gaearon Hey Dan, I created a fiddle about this issue. https://jsfiddle.net/cyan3/k28vxab1/ If you click the button, and hover on the right most div('new'), it will trigger the If you need any help, I'm much willing to do something. |
I don’t really have any idea about where it’s coming from. So you can start looking into how the code path for that event is different (maybe in |
Another possible place is here: https://github.com/facebook/react/blob/master/src/renderers/shared/shared/ReactTreeTraversal.js#L112 There are a few enter/leave issues piling up maybe it's worth getting the switch to native events in there: #10269 |
To clarify, the behavior isn't that there are two |
@jquense this looks like part of the root issue. I'm seeing that for the child divs that aren't triggering |
It’s a valid bug, please don’t close it. |
The issue is with these checks:
They should’ve checked for |
I have a fix in #11164. |
* Add a regression test for #10906 * Turn while conditions into breaks without changing the logic This will be easier to follow when we add more code there. * var => const/let So that I can add a block scoped variable. * Check alternates when comparing to the common ancestor This is the actual bugfix.
React |
It works great, thank you! |
@cyan33 should you do event.stopPropagation(); in your enter function? |
版本(versions):
[email protected]
[email protected]
描述(description):
给父级别绑定 onMouseEnter 事件。在首次渲染后,鼠标移入新渲染进去的子元素会触发父元素的 onMouseEnter 事件。
示例(demo):
The text was updated successfully, but these errors were encountered: