From eb5452173a136e05b1c72c3b764f61c5e867eec0 Mon Sep 17 00:00:00 2001 From: Kieran Boyle Date: Fri, 18 Aug 2017 10:29:58 -0700 Subject: [PATCH] simplify constructor method binding --- src/Select.js | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/Select.js b/src/Select.js index 5baf0d9067..deae2ab067 100644 --- a/src/Select.js +++ b/src/Select.js @@ -43,28 +43,30 @@ class Select extends React.Component { constructor(props) { super(props); - this.handleTouchOutside = this.handleTouchOutside.bind(this); - this.handleTouchMove = this.handleTouchMove.bind(this); - this.handleTouchStart = this.handleTouchStart.bind(this); - this.handleTouchEnd = this.handleTouchEnd.bind(this); - this.handleTouchEndClearValue = this.handleTouchEndClearValue.bind(this); - this.handleMouseDown = this.handleMouseDown.bind(this); - this.handleMouseDownOnArrow = this.handleMouseDownOnArrow.bind(this); - this.handleMouseDownOnMenu = this.handleMouseDownOnMenu.bind(this); - this.handleInputFocus = this.handleInputFocus.bind(this); - this.handleInputBlur = this.handleInputBlur.bind(this); - this.handleInputChange = this.handleInputChange.bind(this); - this.handleInputValueChange = this.handleInputValueChange.bind(this); - this.handleKeyDown = this.handleKeyDown.bind(this); - this.handleValueClick = this.handleValueClick.bind(this); - this.handleMenuScroll = this.handleMenuScroll.bind(this); - this.handleRequired = this.handleRequired.bind(this); - this.getOptionLabel = this.getOptionLabel.bind(this); - this.onOptionRef = this.onOptionRef.bind(this); - this.clearValue = this.clearValue.bind(this); - this.removeValue = this.removeValue.bind(this); - this.selectValue = this.selectValue.bind(this); - this.focusOption = this.focusOption.bind(this); + [ + 'clearValue', + 'focusOption', + 'handleInputBlur', + 'handleInputChange', + 'handleInputFocus', + 'handleInputValueChange', + 'handleKeyDown', + 'handleMenuScroll', + 'handleMouseDown', + 'handleMouseDownOnArrow', + 'handleMouseDownOnMenu', + 'handleRequired', + 'handleTouchOutside', + 'handleTouchMove', + 'handleTouchStart', + 'handleTouchEnd', + 'handleTouchEndClearValue', + 'handleValueClick', + 'getOptionLabel', + 'onOptionRef', + 'removeValue', + 'selectValue' + ].forEach((fn) => this[fn] = this[fn].bind(this)); this.state = { inputValue: '',