<div ref={location} className={style.locations}>
{locations.map(loc => (
<span onClick={onClick}>
{loc.name}
</span>
))}
</div>
I want to access the <span>
inside the <div>
with "location" ref:
const span = location.current.getElementsByTagName("span");
span.forEach(el => {
el.style.display = "none";
})
But I just get error:
span.forEach is not a function