Skip to content

Commit

Permalink
refactor: use more ES6 arrow functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ro-ka committed Jan 4, 2016
1 parent c8ef4c0 commit 2f60e11
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/Geosuggest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ const Geosuggest = React.createClass({
* @param {string} value to set in input
*/
setInputValue: function(value) {
this.setState({
userInput: value
});
this.setState({userInput: value});
},

/**
Expand All @@ -105,10 +103,10 @@ const Geosuggest = React.createClass({
onInputChange: function() {
var userInput = this.refs.geosuggestInput.value;

this.setState({userInput: userInput}, function() {
this.setState({userInput: userInput}, () => {
this.showSuggests();
this.props.onChange(userInput);
}.bind(this));
});
},

/**
Expand All @@ -132,9 +130,7 @@ const Geosuggest = React.createClass({
* Clear the input and close the suggestion pane
*/
clear: function() {
this.setState({userInput: ''}, function() {
this.hideSuggests();
}.bind(this));
this.setState({userInput: ''}, () => this.hideSuggests());
},

/**
Expand Down Expand Up @@ -174,13 +170,13 @@ const Geosuggest = React.createClass({

this.autocompleteService.getPlacePredictions(
options,
function(suggestsGoogle) {
suggestsGoogle => {
this.updateSuggests(suggestsGoogle);

if (this.props.autoActivateFirstSuggest) {
this.activateSuggest('next');
}
}.bind(this)
}
);
},

Expand All @@ -197,7 +193,7 @@ const Geosuggest = React.createClass({
regex = new RegExp(this.state.userInput, 'gim'),
skipSuggest = this.props.skipSuggest;

this.props.fixtures.forEach(function(suggest) {
this.props.fixtures.forEach(suggest => {
if (!skipSuggest(suggest) && suggest.label.match(regex)) {
suggest.placeId = suggest.label;
suggests.push(suggest);
Expand Down Expand Up @@ -229,11 +225,11 @@ const Geosuggest = React.createClass({
*/
hideSuggests: function() {
this.props.onBlur();
setTimeout(function() {
setTimeout(() => {
if (this.state && this.state.isMounted) {
this.setState({isSuggestsHidden: true});
}
}.bind(this), 100);
}, 100);
},

/**
Expand Down Expand Up @@ -329,7 +325,7 @@ const Geosuggest = React.createClass({
geocodeSuggest: function(suggest) {
this.geocoder.geocode(
{address: suggest.label},
function(results, status) {
(results, status) => {
if (status !== this.googleMaps.GeocoderStatus.OK) {
return;
}
Expand All @@ -344,7 +340,7 @@ const Geosuggest = React.createClass({
};

this.props.onSuggestSelect(suggest);
}.bind(this)
}
);
},

Expand Down

0 comments on commit 2f60e11

Please sign in to comment.