Files
insomnia/app/ui/components/base/Button.js
Gregory Schier 1d45367aa1 Added eslint and fixed all problems (#101)
* Fixed duplication kve bug

* Added semistandard and updated code

* Actually got it working

* Even better

* I think it should work on Windows now
2017-03-03 12:09:08 -08:00

36 lines
769 B
JavaScript

import React, {PureComponent, PropTypes} from 'react';
import autobind from 'autobind-decorator';
@autobind
class Button extends PureComponent {
_handleClick (e) {
const {onClick, onDisabledClick, disabled} = this.props;
const fn = disabled ? onDisabledClick : onClick;
if (this.props.hasOwnProperty('value')) {
fn && fn(this.props.value, e);
} else {
fn && fn(e);
}
}
render () {
const {
children,
value, // eslint-disable-line no-unused-vars
...props
} = this.props;
return (
<button {...props} onClick={this._handleClick}>{children}</button>
);
}
}
Button.propTypes = {
value: PropTypes.any,
onDisabledClick: PropTypes.func,
onClick: PropTypes.func
};
export default Button;