Created
September 23, 2016 03:36
-
-
Save ManuelDeLeon/f5d95989f6257a241749170f64ec2f9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { PropTypes } from 'react' | |
const Link = ({ active, children, onClick }) => { | |
if (active) { | |
return <span>{children}</span> | |
} | |
return ( | |
<a href="#" | |
onClick={e => { | |
e.preventDefault() | |
onClick() | |
}} | |
> | |
{children} | |
</a> | |
) | |
} | |
Link.propTypes = { | |
active: PropTypes.bool.isRequired, | |
children: PropTypes.node.isRequired, | |
onClick: PropTypes.func.isRequired | |
} | |
export default Link |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment