My Code : https://codesandbox.io/s/quirky-wescoff-44n2by?file=/src/App.js
When I hover over any element, always the last element of array is printed in console.
I tried using ref, not sure if I am doing it right.
I expected on hover over any element that elements content will be console logged.
Please suggest any way on how to access any elements content on hover.
( I’ll delete this question once its been answered, there were similar questions asked before but I was not able to get them, Gracias! in advance )
2
Answers
Pass the index of the current element as an argument to the enterMouse function.
If I understand your question correctly, you can achieve it without using useRef as follows: