react-google-places-autocomplete
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -147,3 +147,8 @@ 'use strict'; | ||
setTimeout(_this.initalizeService, 500); | ||
var timeoutId = setTimeout(_this.initalizeService, 500); | ||
_this.setState({ | ||
timeoutId: timeoutId | ||
}); | ||
return; | ||
@@ -155,3 +160,8 @@ } | ||
setTimeout(_this.initalizeService, 500); | ||
var _timeoutId = setTimeout(_this.initalizeService, 500); | ||
_this.setState({ | ||
timeoutId: _timeoutId | ||
}); | ||
return; | ||
@@ -163,3 +173,8 @@ } | ||
setTimeout(_this.initializeService, 500); | ||
var _timeoutId2 = setTimeout(_this.initializeService, 500); | ||
_this.setState({ | ||
timeoutId: _timeoutId2 | ||
}); | ||
return; | ||
@@ -171,3 +186,4 @@ } | ||
_this.setState({ | ||
placesServiceStatus: window.google.maps.places.PlacesServiceStatus.OK | ||
placesServiceStatus: window.google.maps.places.PlacesServiceStatus.OK, | ||
timeoutId: null | ||
}); | ||
@@ -369,2 +385,3 @@ | ||
suggestions: [], | ||
timeoutId: null, | ||
value: props.initialValue | ||
@@ -389,2 +406,8 @@ }; | ||
_proto.componentWillUnmount = function componentWillUnmount() { | ||
var timeoutId = this.state.timeoutId; | ||
if (timeoutId) { | ||
clearTimeout(timeoutId); | ||
} | ||
removeScript(); | ||
@@ -391,0 +414,0 @@ document.removeEventListener('click', this.handleClick); |
@@ -141,9 +141,25 @@ "use strict"; | ||
}), _this.props.debounce)), _defineProperty(_assertThisInitialized(_this), "initalizeService", (function() { | ||
return window.google ? window.google.maps ? window.google.maps.places ? (_this.placesService = new window.google.maps.places.AutocompleteService, | ||
if (window.google) if (window.google.maps) if (window.google.maps.places) _this.placesService = new window.google.maps.places.AutocompleteService, | ||
_this.setState({ | ||
placesServiceStatus: window.google.maps.places.PlacesServiceStatus.OK | ||
}), void _this.generateSessionToken()) : (console.error("[react-google-places-autocomplete]: Google maps places script not loaded"), | ||
void setTimeout(_this.initializeService, 500)) : (console.error("[react-google-places-autocomplete]: Google maps script not loaded"), | ||
void setTimeout(_this.initalizeService, 500)) : (console.error("[react-google-places-autocomplete]: Google script not loaded"), | ||
void setTimeout(_this.initalizeService, 500)); | ||
placesServiceStatus: window.google.maps.places.PlacesServiceStatus.OK, | ||
timeoutId: null | ||
}), _this.generateSessionToken(); else { | ||
console.error("[react-google-places-autocomplete]: Google maps places script not loaded"); | ||
var _timeoutId2 = setTimeout(_this.initializeService, 500); | ||
_this.setState({ | ||
timeoutId: _timeoutId2 | ||
}); | ||
} else { | ||
console.error("[react-google-places-autocomplete]: Google maps script not loaded"); | ||
var _timeoutId = setTimeout(_this.initalizeService, 500); | ||
_this.setState({ | ||
timeoutId: _timeoutId | ||
}); | ||
} else { | ||
console.error("[react-google-places-autocomplete]: Google script not loaded"); | ||
var timeoutId = setTimeout(_this.initalizeService, 500); | ||
_this.setState({ | ||
timeoutId: timeoutId | ||
}); | ||
} | ||
})), _defineProperty(_assertThisInitialized(_this), "generateSessionToken", (function() { | ||
@@ -262,2 +278,3 @@ var sessionToken = new google.maps.places.AutocompleteSessionToken; | ||
suggestions: [], | ||
timeoutId: null, | ||
value: props.initialValue | ||
@@ -272,3 +289,4 @@ }, _this; | ||
}, _proto.componentWillUnmount = function() { | ||
removeScript(), document.removeEventListener("click", this.handleClick); | ||
var timeoutId = this.state.timeoutId; | ||
timeoutId && clearTimeout(timeoutId), removeScript(), document.removeEventListener("click", this.handleClick); | ||
}, _proto.UNSAFE_componentWillReceiveProps = function(nextProps) { | ||
@@ -275,0 +293,0 @@ var initialValue = this.props.initialValue; |
@@ -141,3 +141,8 @@ import React from 'react'; | ||
setTimeout(_this.initalizeService, 500); | ||
var timeoutId = setTimeout(_this.initalizeService, 500); | ||
_this.setState({ | ||
timeoutId: timeoutId | ||
}); | ||
return; | ||
@@ -149,3 +154,8 @@ } | ||
setTimeout(_this.initalizeService, 500); | ||
var _timeoutId = setTimeout(_this.initalizeService, 500); | ||
_this.setState({ | ||
timeoutId: _timeoutId | ||
}); | ||
return; | ||
@@ -157,3 +167,8 @@ } | ||
setTimeout(_this.initializeService, 500); | ||
var _timeoutId2 = setTimeout(_this.initializeService, 500); | ||
_this.setState({ | ||
timeoutId: _timeoutId2 | ||
}); | ||
return; | ||
@@ -165,3 +180,4 @@ } | ||
_this.setState({ | ||
placesServiceStatus: window.google.maps.places.PlacesServiceStatus.OK | ||
placesServiceStatus: window.google.maps.places.PlacesServiceStatus.OK, | ||
timeoutId: null | ||
}); | ||
@@ -363,2 +379,3 @@ | ||
suggestions: [], | ||
timeoutId: null, | ||
value: props.initialValue | ||
@@ -383,2 +400,8 @@ }; | ||
_proto.componentWillUnmount = function componentWillUnmount() { | ||
var timeoutId = this.state.timeoutId; | ||
if (timeoutId) { | ||
clearTimeout(timeoutId); | ||
} | ||
removeScript(); | ||
@@ -385,0 +408,0 @@ document.removeEventListener('click', this.handleClick); |
{ | ||
"name": "react-google-places-autocomplete", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "Google places autocomplete input for ReactJS.", | ||
@@ -5,0 +5,0 @@ "main": "dist/react-google-places-autocomplete.cjs.js", |
@@ -39,2 +39,3 @@ import React from 'react'; | ||
suggestions: [], | ||
timeoutId: null, | ||
value: props.initialValue, | ||
@@ -56,2 +57,8 @@ }; | ||
componentWillUnmount() { | ||
const { timeoutId } = this.state; | ||
if (timeoutId) { | ||
clearTimeout(timeoutId); | ||
} | ||
removeScript(); | ||
@@ -72,3 +79,4 @@ document.removeEventListener('click', this.handleClick); | ||
console.error('[react-google-places-autocomplete]: Google script not loaded'); // eslint-disable-line no-console | ||
setTimeout(this.initalizeService, 500); | ||
const timeoutId = setTimeout(this.initalizeService, 500); | ||
this.setState({ timeoutId }); | ||
return; | ||
@@ -79,3 +87,4 @@ } | ||
console.error('[react-google-places-autocomplete]: Google maps script not loaded'); // eslint-disable-line no-console | ||
setTimeout(this.initalizeService, 500); | ||
const timeoutId = setTimeout(this.initalizeService, 500); | ||
this.setState({ timeoutId }); | ||
return; | ||
@@ -86,3 +95,4 @@ } | ||
console.error('[react-google-places-autocomplete]: Google maps places script not loaded'); // eslint-disable-line no-console | ||
setTimeout(this.initializeService, 500); | ||
const timeoutId = setTimeout(this.initializeService, 500); | ||
this.setState({ timeoutId }); | ||
return; | ||
@@ -92,3 +102,6 @@ } | ||
this.placesService = new window.google.maps.places.AutocompleteService(); | ||
this.setState({ placesServiceStatus: window.google.maps.places.PlacesServiceStatus.OK }); | ||
this.setState({ | ||
placesServiceStatus: window.google.maps.places.PlacesServiceStatus.OK, | ||
timeoutId: null, | ||
}); | ||
this.generateSessionToken(); | ||
@@ -95,0 +108,0 @@ } |
279892
1921