Skip to content

Commit 02a7a67

Browse files
committed
Merge pull request #70 from Aweary/patch-1
Make clickHandler registration more clear
2 parents 95481a8 + 7f9af36 commit 02a7a67

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

components/Button/Button.react.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import PropTypes from 'lib/PropTypes';
1010
import React from 'react';
1111
import styles from 'components/Button/Button.scss';
1212

13+
const noop = () => {};
14+
1315
let Button = (props) => {
16+
const hasOnClick = props.onClick && !props.disabled;
1417
let classes = [styles.button, unselectable];
1518
// if a button is disabled, that overrides any color selection
1619
if (props.disabled) {
@@ -30,9 +33,7 @@ let Button = (props) => {
3033
classes.push(styles.progress);
3134
}
3235
}
33-
let clickHandler = (props.onClick && !props.disabled) ?
34-
props.onClick :
35-
function() { };
36+
let clickHandler = hasOnClick ? props.onClick : noop;
3637
let styleOverride = null;
3738
if (props.width) {
3839
styleOverride = { width: props.width, minWidth: props.width, ...props.additionalStyles };

0 commit comments

Comments
 (0)