Files
freeCodeCamp/common/app/utils/Language-Link.jsx
2016-07-28 23:40:01 -07:00

31 lines
619 B
JavaScript

import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router';
import { addLang } from './add-lang';
const mapStateToProps = state => ({ lang: state.app.lang });
export class LangLink extends React.Component {
static displayName = 'LangLink';
static propTypes = {
to: PropTypes.string,
lang: PropTypes.string
};
render() {
const {
to,
lang,
...props
} = this.props;
return (
<Link
to={ addLang(to, lang) }
{ ...props }
/>
);
}
}
export default connect(mapStateToProps)(LangLink);