0
0
Fork 0

Use ES Class Fields & Static Properties (#3008)

Use ES Class Fields & Static Properties (currently stage 2) for improve class outlook.

Added babel-plugin-transform-class-properties as a Babel plugin.
This commit is contained in:
Yamagishi Kazutoshi 2017-05-12 21:44:10 +09:00 committed by Eugen Rochko
parent 44a3584e2d
commit 2991a7cfe6
79 changed files with 838 additions and 1128 deletions

View file

@ -4,20 +4,27 @@ import PropTypes from 'prop-types';
class DropdownMenu extends React.PureComponent {
constructor (props, context) {
super(props, context);
this.state = {
direction: 'left'
};
this.setRef = this.setRef.bind(this);
this.renderItem = this.renderItem.bind(this);
}
static propTypes = {
icon: PropTypes.string.isRequired,
items: PropTypes.array.isRequired,
size: PropTypes.number.isRequired,
direction: PropTypes.string,
ariaLabel: PropTypes.string
};
setRef (c) {
static defaultProps = {
ariaLabel: "Menu"
};
state = {
direction: 'left'
};
setRef = (c) => {
this.dropdown = c;
}
handleClick (i, e) {
handleClick = (i, e) => {
const { action } = this.props.items[i];
if (typeof action === 'function') {
@ -27,7 +34,7 @@ class DropdownMenu extends React.PureComponent {
}
}
renderItem (item, i) {
renderItem = (item, i) => {
if (item === null) {
return <li key={ 'sep' + i } className='dropdown__sep' />;
}
@ -64,16 +71,4 @@ class DropdownMenu extends React.PureComponent {
}
DropdownMenu.propTypes = {
icon: PropTypes.string.isRequired,
items: PropTypes.array.isRequired,
size: PropTypes.number.isRequired,
direction: PropTypes.string,
ariaLabel: PropTypes.string
};
DropdownMenu.defaultProps = {
ariaLabel: "Menu"
};
export default DropdownMenu;