React: onMouseOut does not behave as expected with nested elements

Created on 13 Sep 2014  路  2Comments  路  Source: facebook/react

given the following:

React.renderComponent(
    <div onMouseOut={ function() { console.log('here'); } } style={{width: '100px', height:'100px', backgroundColor:'#ccc'}}><div style={{width: '50px', height:'50px', backgroundColor:'#aaa'}}>a</div></div>,
    document.getElementById('example')
);

when you mouse over the smaller square within the bigger square, the onMouseOut of the bigger square gets called, despite the mouse still being contained within it.

Most helpful comment

This is no different from the same events outside of React. You probably want onMouseLeave.

All 2 comments

This is no different from the same events outside of React. You probably want onMouseLeave.

Ah, oops. thanks.

Was this page helpful?
0 / 5 - 0 ratings