Spaces:
Running
Running
File size: 1,094 Bytes
f2bee8a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import bindAll from 'lodash.bindall';
import PropTypes from 'prop-types';
import React from 'react';
import {MenuItem as MenuItemComponent} from '../components/menu/menu.jsx';
class MenuItem extends React.Component {
constructor (props) {
super(props);
bindAll(this, [
'navigateToHref'
]);
}
navigateToHref () {
if (this.props.href) window.location.href = this.props.href;
}
render () {
const {
children,
className,
onClick
} = this.props;
const clickAction = onClick ? onClick : this.navigateToHref;
return (
<MenuItemComponent
className={className}
onClick={clickAction}
>
{children}
</MenuItemComponent>
);
}
}
MenuItem.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
// can take an onClick prop, or take an href and build an onClick handler
href: PropTypes.string,
onClick: PropTypes.func
};
export default MenuItem;
|