1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/test/integration/basic/pages/nav/pass-href-prop.js
Victor Borges 6e7ac5f0ef fix: Forces Link to expose the href to the child using passHref property. (#2503)
* Forces Link to exposes the href to the child using passHref property.

* tests for passHref prop of the Link

* passHref property Link documentation
2017-07-09 10:39:02 +05:30

28 lines
621 B
JavaScript

import Link from 'next/link'
const UnexpectedNestedA = () => {
const UnexpectedWrapper = (props) => {
const {href, id} = props
const safeProps = {href, id}
return (<a {...safeProps}>{props.children}</a>)
}
return UnexpectedWrapper
}
const FakeA = UnexpectedNestedA()
export default () => (
<div className='nav-pass-href-prop'>
<Link href='/nav' passHref>
<FakeA id='with-href'>Will redirect as an `a` tag</FakeA>
</Link>
<Link href='/nav'>
<FakeA id='without-href'>Will not redirect as an `a` tag</FakeA>
</Link>
<p>This is the passHref prop page.</p>
</div>
)