Skip to content

Commit

Permalink
(fix) Debounce not working
Browse files Browse the repository at this point in the history
  • Loading branch information
hhunaid committed Jan 7, 2018
1 parent 708c52a commit d48acaa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/AutoCompleteInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,18 @@ const REVRSE_GEO_CODE_URL = "https://maps.googleapis.com/maps/api/geocode/json";
export default class AutoCompleteInput extends React.Component {
static propTypes = {
apiKey: PropTypes.string.isRequired,
language: PropTypes.string
language: PropTypes.string,
debounceDuration: PropTypes.number.isRequired
};

static defaultProps = {
language: 'en'
};

constructor() {
super();
constructor(props) {
super(props);
this._onChangeText = this._onChangeText.bind(this);
this._request = debounce(this._request.bind(this), 300);
this._request = debounce(this._request.bind(this), this.props.debounceDuration);
this._abortRequest = this._abortRequest.bind(this);
this.fetchAddressForLocation = this.fetchAddressForLocation.bind(this);
this.blur = this.blur.bind(this);
Expand Down
3 changes: 2 additions & 1 deletion src/LocationView.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class LocationView extends React.Component {
markerColor: 'black',
actionText: 'DONE',
onLocationSelect: () => ({}),
debounceDuration: 200
debounceDuration: 300
};

constructor(props) {
Expand Down Expand Up @@ -144,6 +144,7 @@ export default class LocationView extends React.Component {
ref={input => this._input = input}
apiKey={this.props.apiKey}
style={[styles.input, {transform: [{scale: inputScale}]}]}
debounceDuration={this.props.debounceDuration}
/>
</View>
<TouchableOpacity style={styles.currentLocBtn} onPress={this._getCurrentLocation}>
Expand Down

0 comments on commit d48acaa

Please sign in to comment.