insomnia/app/ui/components/base/Button.js
Gregory Schier b198e6170b React performance sweep (#96)
* Removed some unnecessary rendering

* Only PureComponents and some other stuff

* Removed all functional components

* Only deal with nunjucks marks

* Remove ref assign functions in modals

* Lots of tweaks

* A bit snappier

* A bit snappier
2017-02-28 13:32:23 -08:00

31 lines
690 B
JavaScript

import React, {PureComponent, PropTypes} from 'react';
import {shell} from 'electron';
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, ...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;