Skip to content

Commit 792172e

Browse files
committed
bind instance methods via class property arrow function
1 parent e1d0650 commit 792172e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/scripts/Lookup.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ export class LookupSearch extends Component {
107107
]);
108108
}
109109

110-
onLookupIconClick() {
110+
onLookupIconClick = () => {
111111
this.props.onSubmit();
112112
}
113113

114-
onInputKeyDown(e) {
114+
onInputKeyDown = (e) => {
115115
if (e.keyCode === 13) { // return key
116116
e.preventDefault();
117117
e.stopPropagation();
@@ -138,7 +138,7 @@ export class LookupSearch extends Component {
138138
}
139139
}
140140

141-
onInputChange(e) {
141+
onInputChange = (e) => {
142142
const searchText = e.target.value;
143143
this.props.onChange(searchText);
144144
}
@@ -153,13 +153,13 @@ export class LookupSearch extends Component {
153153
}, 10);
154154
}
155155

156-
onScopeMenuClick(e) {
156+
onScopeMenuClick = (e) => {
157157
if (this.props.onScopeMenuClick) {
158158
this.props.onScopeMenuClick(e);
159159
}
160160
}
161161

162-
onMenuItemClick(scope) {
162+
onMenuItemClick = (scope) => {
163163
if (this.props.onScopeChange) {
164164
this.props.onScopeChange(scope.value);
165165
}
@@ -205,9 +205,9 @@ export class LookupSearch extends Component {
205205
{ ...pprops }
206206
inputRef={ node => (this.input = node) }
207207
value={ searchText }
208-
onKeyDown={ this.onInputKeyDown.bind(this) }
209-
onChange={ this.onInputChange.bind(this) }
210-
onBlur={ this.onInputBlur.bind(this) }
208+
onKeyDown={ this.onInputKeyDown }
209+
onChange={ this.onInputChange }
210+
onBlur={ this.onInputBlur }
211211
/>
212212
<span
213213
tabIndex={ -1 }
@@ -242,9 +242,9 @@ export class LookupSearch extends Component {
242242
<div className={ selectorClassNames }>
243243
<DropdownButton
244244
label={ icon }
245-
onClick={ this.onScopeMenuClick.bind(this) }
246-
onMenuItemClick={ this.onMenuItemClick.bind(this) }
247-
onBlur={ this.onInputBlur.bind(this) }
245+
onClick={ this.onScopeMenuClick }
246+
onMenuItemClick={ this.onMenuItemClick }
247+
onBlur={ this.onInputBlur }
248248
>
249249
{ scopes.map(scope => <DropdownMenuItem key={ scope.value } { ...scope } />) }
250250
</DropdownButton>

0 commit comments

Comments
 (0)