I have this code in react 17.0.2, and I hope that when I hover over a section, the onMouseOver function that I pass to the component by props is executed.
This function just prints a console.log of the e.target
.
When I hover over the section, I correctly see on console <section id="amenities"... />
, but if I hover over any inner element of this section, the inner element is now consoled. Is there a way to ALWAYS get as e.target
the parent section
element instead of its inner elements?
<section
className="resort-amenities"
id="amenities"
onMouseEnter={onMouseOver}
>
<h2 className="title">Amenities</h2>
<div className="amenities-wrapper">
{renderAmenities}
</div>
</section>
cont onMouseOver = () => console.log(e.target)