mirror of
https://github.com/Kong/insomnia.git
synced 2026-04-21 14:47:46 -04:00
* Fixed duplication kve bug * Added semistandard and updated code * Actually got it working * Even better * I think it should work on Windows now
36 lines
769 B
JavaScript
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;
|