Skip to content

Instantly share code, notes, and snippets.

@prichodko
Last active September 5, 2018 12:08
Show Gist options
  • Save prichodko/5e14552dd21c14d5e6e480b2befafa84 to your computer and use it in GitHub Desktop.
Save prichodko/5e14552dd21c14d5e6e480b2befafa84 to your computer and use it in GitHub Desktop.
import styled from 'styled-components' // using upcoming `as` prop in v4
import { Link } from 'react-router-dom'
const Button = styled.button`
// styles
`
export default props => {
if (props.href) {
<Button as="a" {...props} rel="noreferrer noopener" target="_blank" />
}
if (props.to) {
<Button as={Link} {...props} />
}
return <Button {...props} />
}
// you can easily create a factory if needed
const makeUniversal = Component => props => { ... }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment