Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update next/link docs to not include example without href #19247

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions docs/api-reference/next/link.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,27 +197,6 @@ The default behavior of the `Link` component is to `push` a new URL into the `hi
</Link>
```

## Using a component that supports `onClick`

`Link` supports any component that supports the `onClick` event, in the case you don't provide an `<a>` tag, consider the following example:

```jsx
import Link from 'next/link'
import Image from 'next/image'

function Avatar() {
return (
<Link href="/about">
<Image src="/me.png" alt="me" width="64" height="64" />
</Link>
)
}

export default Avatar
```

The child of `Link` is [`Image`](/docs/api-reference/next/image.md) instead of `<a>`. `Link` will send the `onClick` property to `Image` but won't pass the `href` property.

## Disable scrolling to the top of the page

The default behavior of `Link` is to scroll to the top of the page. When there is a hash defined it will scroll to the specific id, like a normal `<a>` tag. To prevent scrolling to the top / hash `scroll={false}` can be added to `Link`:
Expand Down