File tree 6 files changed +13
-3
lines changed
6 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export interface ReactGoogleAutocompleteProps {
9
9
inputAutocompleteValue ?: string ;
10
10
options ?: google . maps . places . AutocompleteOptions ;
11
11
apiKey ?: string ;
12
+ language ?: string ;
12
13
}
13
14
14
15
export interface ReactGoogleAutocompleteInputProps
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ function usePlacesWidget(props) {
45
45
var event = ( 0 , _react . useRef ) ( null ) ;
46
46
var autocompleteRef = ( 0 , _react . useRef ) ( null ) ;
47
47
var observerHack = ( 0 , _react . useRef ) ( null ) ;
48
- var languageQueryParam = language ? "&language=" . concat ( language ) : '' ;
48
+ var languageQueryParam = language ? "&language=" . concat ( language ) : "" ;
49
49
var googleMapsScriptUrl = "" . concat ( googleMapsScriptBaseUrl , "?libraries=places&key=" ) . concat ( apiKey ) . concat ( languageQueryParam ) ;
50
50
var handleLoadScript = ( 0 , _react . useCallback ) ( function ( ) {
51
51
return ( 0 , _utils . loadGoogleMapScript ) ( googleMapsScriptBaseUrl , googleMapsScriptUrl ) ;
Original file line number Diff line number Diff line change @@ -9,6 +9,11 @@ exports.isBrowser = isBrowser;
9
9
10
10
var loadGoogleMapScript = function loadGoogleMapScript ( googleMapsScriptBaseUrl , googleMapsScriptUrl ) {
11
11
if ( ! isBrowser ) return Promise . resolve ( ) ;
12
+
13
+ if ( typeof google !== "undefined" ) {
14
+ if ( google . maps && google . maps . api ) return Promise . resolve ( ) ;
15
+ }
16
+
12
17
var scriptElements = document . querySelectorAll ( "script[src*=\"" . concat ( googleMapsScriptBaseUrl , "\"" ) ) ;
13
18
14
19
if ( scriptElements && scriptElements . length ) {
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " react-google-autocomplete" ,
3
- "version" : " 2.3.0 " ,
3
+ "version" : " 2.3.1 " ,
4
4
"description" : " React component for google autocomplete." ,
5
5
"main" : " index.js" ,
6
6
"types" : " index.d.ts" ,
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export default function usePlacesWidget(props) {
28
28
const event = useRef ( null ) ;
29
29
const autocompleteRef = useRef ( null ) ;
30
30
const observerHack = useRef ( null ) ;
31
- const languageQueryParam = language ? `&language=${ language } ` : '' ;
31
+ const languageQueryParam = language ? `&language=${ language } ` : "" ;
32
32
const googleMapsScriptUrl = `${ googleMapsScriptBaseUrl } ?libraries=places&key=${ apiKey } ${ languageQueryParam } ` ;
33
33
34
34
const handleLoadScript = useCallback (
Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ export const loadGoogleMapScript = (
6
6
) => {
7
7
if ( ! isBrowser ) return Promise . resolve ( ) ;
8
8
9
+ if ( typeof google !== "undefined" ) {
10
+ if ( google . maps && google . maps . api ) return Promise . resolve ( ) ;
11
+ }
12
+
9
13
const scriptElements = document . querySelectorAll (
10
14
`script[src*="${ googleMapsScriptBaseUrl } "`
11
15
) ;
You can’t perform that action at this time.
0 commit comments