upgraded to react router v4
This commit is contained in:
@ -1,31 +1,20 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import { browserHistory } from 'react-router';
|
||||
|
||||
import styles from './DropdownMenu.scss';
|
||||
|
||||
class MenuItem extends React.Component {
|
||||
onClick = () => {
|
||||
if (this.props.to) {
|
||||
browserHistory.push(this.props.to);
|
||||
} else {
|
||||
this.props.onClick();
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className={styles.menuItem} onClick={this.onClick}>
|
||||
{this.props.children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem.propTypes = {
|
||||
onClick: React.PropTypes.func,
|
||||
to: React.PropTypes.string,
|
||||
children: React.PropTypes.node.isRequired,
|
||||
const MenuItem = ({
|
||||
onClick,
|
||||
children,
|
||||
}: {
|
||||
onClick?: Function,
|
||||
children?: React.Element<any>,
|
||||
}) => {
|
||||
return (
|
||||
<div className={styles.menuItem} onClick={onClick}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
//
|
||||
|
Reference in New Issue
Block a user