I want to remove the classList whenever the route changes in Next.js, I am trying this :
React.useEffect(() => {
const activatedLink = router.query.tags
const classActivated = document.querySelector('.'+activatedLink)
if(router.asPath) {
classActivated?.classList.add('link-on')
}
else classActivated?.classList.remove('link-on')
}, [router.asPath])
Any idea how to remove the classList when the route changes ?