react-google-autocomplete
Advanced tools
Comparing version 2.7.0 to 2.7.1
@@ -70,3 +70,3 @@ import React, { FC, RefObject, useRef, useState } from "react"; | ||
inputComponent={({ inputRef, onFocus, onBlur, ...props }) => ( | ||
<AutocompleteComponent | ||
<Autocomplete | ||
apiKey={process.env.REACT_APP_GOOGLE} | ||
@@ -73,0 +73,0 @@ {...props} |
@@ -80,7 +80,10 @@ "use strict"; | ||
autocompleteRef.current = new google.maps.places.Autocomplete(inputRef.current, config); | ||
event.current = autocompleteRef.current.addListener("place_changed", function () { | ||
if (onPlaceSelected && autocompleteRef && autocompleteRef.current) { | ||
onPlaceSelected(autocompleteRef.current.getPlace(), inputRef.current, autocompleteRef.current); | ||
} | ||
}); | ||
if (autocompleteRef.current) { | ||
event.current = autocompleteRef.current.addListener("place_changed", function () { | ||
if (onPlaceSelected && autocompleteRef && autocompleteRef.current) { | ||
onPlaceSelected(autocompleteRef.current.getPlace(), inputRef.current, autocompleteRef.current); | ||
} | ||
}); | ||
} | ||
}; | ||
@@ -87,0 +90,0 @@ |
{ | ||
"name": "react-google-autocomplete", | ||
"version": "2.7.0", | ||
"version": "2.7.1", | ||
"description": "React component for google autocomplete.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -147,3 +147,3 @@ ![](/docs/example.gif) | ||
if (placePredictions.length) | ||
service.placesService?.getDetails( | ||
placesService?.getDetails( | ||
{ | ||
@@ -150,0 +150,0 @@ placeId: placePredictions[0].place_id, |
@@ -72,15 +72,17 @@ import React, { useEffect, useRef, useCallback } from "react"; | ||
); | ||
event.current = autocompleteRef.current.addListener( | ||
"place_changed", | ||
() => { | ||
if (onPlaceSelected && autocompleteRef && autocompleteRef.current) { | ||
onPlaceSelected( | ||
autocompleteRef.current.getPlace(), | ||
inputRef.current, | ||
autocompleteRef.current | ||
); | ||
if(autocompleteRef.current) { | ||
event.current = autocompleteRef.current.addListener( | ||
"place_changed", | ||
() => { | ||
if (onPlaceSelected && autocompleteRef && autocompleteRef.current) { | ||
onPlaceSelected( | ||
autocompleteRef.current.getPlace(), | ||
inputRef.current, | ||
autocompleteRef.current | ||
); | ||
} | ||
} | ||
} | ||
); | ||
); | ||
} | ||
}; | ||
@@ -87,0 +89,0 @@ |
402542
1046