Last active
February 15, 2019 22:36
-
-
Save rafaelrozon/c83beecc9e598bb82e83668a8edcbf2e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Link - Component | |
*/ | |
import React from 'react'; | |
import PropTypes from 'prop-types'; | |
import { Link as RRDLink } from "react-router-dom"; | |
import { translate } from '~/decorators'; | |
import { Icon } from 'antd'; | |
@translate | |
export default class Link extends React.Component { | |
static propTypes = { | |
children: PropTypes.element, | |
icon: PropTypes.string, | |
route: PropTypes.string.isRequired, | |
text: PropTypes.string, | |
withIcon: PropTypes.bool, | |
t: PropTypes.func.isRequired | |
}; | |
static defaultProps = { | |
params: {}, | |
withIcon: false, | |
children: null, | |
text: '' | |
}; | |
render() { | |
const { children, icon, route, text, withIcon, t } = this.props; | |
return ( | |
<RRDLink to={route}> | |
{withIcon && <Icon type={icon} />} | |
{children || t(text)} | |
</RRDLink> | |
); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment