Skip to content

Commit

Permalink
doc: fix ActiveLink detection condition (#23472)
Browse files Browse the repository at this point in the history
## Documentation / Examples

- [x] Make sure the linting passes


`router.pathname` can be dynamic routes like `/posts/[slug]`, use `router.asPath` instead to detect anchor is active
  • Loading branch information
huozhi authored Mar 28, 2021
1 parent 9973b8c commit 737c25e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/api-reference/next/router.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function ActiveLink({ children, href }) {
const router = useRouter()
const style = {
marginRight: 10,
color: router.pathname === href ? 'red' : 'black',
color: router.asPath === href ? 'red' : 'black',
}

const handleClick = (e) => {
Expand Down

0 comments on commit 737c25e

Please sign in to comment.