Unverified Commit b955268d authored by Luis Alvarez D's avatar Luis Alvarez D Committed by GitHub

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

Co-authored-by: 's avatarkodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
parent 0f5db2a5
...@@ -197,27 +197,6 @@ The default behavior of the `Link` component is to `push` a new URL into the `hi ...@@ -197,27 +197,6 @@ The default behavior of the `Link` component is to `push` a new URL into the `hi
</Link> </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 ## 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`: 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`:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment