-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
Link as a StyledComponent #799
Comments
@timneutkens in this case the import Link from 'next/prefetch'
import styled from 'styled-components'
const MenuItem = styled.li`
margin: 0 10px;
list-style: none;
`;
const MenuLink = styled(Link)`
font-weight: 700;
line-height: 2.88;
`
export default () => (
<MenuItem>
<MenuLink href='/signin'>
<a>Sign In</a>
</MenuLink>
<MenuItem>
) Result: <li class="cjJDVk" data-reactid="8">
<a href="/signin" data-reactid="9">Sign In</a>
</li> |
@jlcarvalho Yes, you should style the import Link from 'next/prefetch'
import styled from 'styled-components'
const MenuLink = styled.a`
font-weight: 700;
line-height: 2.88;
`
export default () => (
<Link href='/signin'>
<MenuLink>Sign In</MenuLink>
</Link>
) |
@impronunciable I tried, but the output was: <li class="ePmGlD">
<a href="/signin">
<a class="jbHZic">Sign In</a>
</a>
</li> |
Oh, I see. That's because the styled component is not an anchor. We are going to deprecate this behavior but I don't see a fix for this in the meanwhile |
Exactly as @jlcarvalho said. @impronunciable, why does it matters for Link the Element.type of its first child? I think it could only provide the click behavior. Currently it's only discouraging composability. |
Please see #816 👍 |
I tried this and it seems to be working fine?
|
The way Link is implemented right now, it's impossible to compose styles using styled-components without generating
<a><a></a></a>
.#241 would solve. Any updates on turning
Link
a behavior decorator only?The text was updated successfully, but these errors were encountered: