Passing active class to a state hook
xBis7 opened this issue · comments
I have a menu styled with react semantic ui. Highlighting the active item comes from a state hook that holds the according id.
Instead of using css to highlight the active item
.active-scroll-spy {
background-color: yellowgreen;
border-radius: 15px;
}
I would like to be able to get the id from the activeClass
and store it in the useState()
hook and access it from there to update the menu. I can see that react-ui-scrollspy
works as expected from the updated url path. Is it possible to have access to the active class id to manipulate it with JavaScript code?
I found what I was looking for, in closed issues from this repo. Just for reference, we can access the id
<ScrollSpy onUpdateCallback={(id) => setActiveItem(id)}>
. If anyone has a better solution, please leave a comment. Closing the issue.