Let's imagine I have this :
<div className='parent'>
<div className='child'></div>
<div className='child-1'></div>
<div className='child'></div>
<div className='child-1></div>
</div>
And let's imagine you have a dropdown How can I target the child-1 components with the onMouseEnter function by hovering the parent component? I'm new to react, can't find an answer, please
you can use useRef hook to get the child element
import React, { useRef } from "react";
import "./styles.css";
export default function App() {
const parentRef = useRef(null);
const doSomething = () => {
console.log(parentRef.current.children);
};
return (
<div className='parent' ref={parentRef} onMouseOver={doSomething}>
<div className='child'></div>
<div className='child-1'></div>
<div className='child'></div>
<div className='child-1></div>
</div>
);
}