Hello
I have used a map function to create a list of elements.
When there is a mouseEnter in one of these elements, it should change the visibility of the sibling element (div classname="prompt")
The problem is : this changes the visibility for all of them.
Even if I add an index to the (div classname="prompt") it doesn't work.
Here are the key code involved :
const [showElement, setShowElement] = useState(false);
return (
{images.map((index, i) => {
return (
<div className="itemVert" >
<div className="item" key={i}
onMouseEnter={() => setShowElement(true)} onMouseLeave={() => setShowElement(false)}>
<img src={`./images/${myjson.images[index].name}`} alt="" />
</div>
<div className="prompt"
style={{ visibility: showElement ? 'visible' : 'hidden' }}
>{myjson.images[index].prompt}
</div>
</div>
})