fisshy / react-scroll

React scroll component
https://github.com/fisshy/react-scroll/blob/master/README.md
MIT License
4.36k stars 437 forks source link

activeClass prop not works #507

Open marccmartian opened 2 years ago

marccmartian commented 2 years ago

I'm working with react v18 and react router dom v6 Everything is ok but the activeClass prop doesn't works. I think It's not compatible yet...

I have inspected the console and in the html when I click the link, it doesn't generate the "active" class.

<Link
  to='about'
  smooth={true}
  duration={1000}
  activeClass='active'
  spy={true}
>
  HELLO
</Link>
pgreber2504 commented 2 years ago

Hello, I have the same problem as above. I'm working with react v18.1 and Next.js v12.1.6. I try to debug this by reactdevtools and i see that state of link doesn't change. Active stay always on false

Screenshot 2022-05-26 at 09 13 03
crespire commented 2 years ago

Experiencing the same. I was experiencing this issue, but seemed to have fixed it?

In my case, I had one link that I had set spy={false} while wanting to spy on other links. Setting spy={true} for all links seemed to resolve the issue, as I am now getting the correct activeClass styles.

yassineelhoubi commented 1 year ago

hacky solution,

<Link activeClass='active' smooth spy to={item.key} onSetActive={()=>{setActiveSection(item.key)}}>