makotot/react-scrollspy

How to get the element that was clicked on

Opened this issue · 1 comments

Function onUpdate() return element which was scrolled.
Is there a possibility get element that was clicked ?

After all, currentСlass is-current is added to element.
Please help.

The callback function passed into onUpdate seems to be passing back the DOM element.

You can pass an anonymous function to pass element into your handle function.
onUpdate={element => handleOnUpdate(element)}

And then your handle function can be declared with a parameter which knows which DOM element was scrolled to.

function handleOnUpdate(element){
    //code here
}