title |
---|
Link `passHref` |
Ensure
passHref
is used with customLink
components.
passHref
was not used for a Link
component that wraps a custom component. This is needed in order to pass the href
to the child <a>
tag.
If you're using a custom component that wraps an <a>
tag, make sure to add passHref
and legacyBehavior
:
import Link from 'next/link'
import styled from 'styled-components'
const StyledLink = styled.a`
color: red;
`
function NavLink({ href, name }) {
return (
<Link href={href} passHref legacyBehavior>
<StyledLink>{name}</StyledLink>
</Link>
)
}
export default NavLink