hack4impact-uiuc / bridge

Hack4Impact UIUC Design System + React Components
https://uiuc.hack4impact.org/design
MIT License
12 stars 4 forks source link

Using Bridge Link component with React Router Dom Link component #99

Closed angadgarg25 closed 4 years ago

angadgarg25 commented 4 years ago

I'd like to use the functionality of the Link component from react-router-dom with the styling of the Link component from bridge. Any way to do that? I'm currently doing this:

import { Link as RRLink } from 'react-router-dom'
import { Link } from '@hack4impact-uiuc/bridge'

const MyLink = ({ id }) => (
  <RRLink to={`/workspace/${id}`}>
    <Link as="p">View Workspace</Link>
  </RRLink>
)

This does have the desired functionality, BUT I get errors printing to the console about nesting a tags, since this generates something along the lines of:

<a>
  <a> <a/>
</a>

Is there a better fix for this? BTW, really enjoying working with this design system, great job to the team!

tko22 commented 4 years ago

Each component has an as prop that allows you to set the components html tag https://styled-components.com/docs/api#as-polymorphic-prop. So you could do

<RRLink>
    <Link as="span">Some Link text here</Link>
</RRLink>
angadgarg25 commented 4 years ago

ah perfect, thanks!