File tree Expand file tree Collapse file tree 6 files changed +13
-3
lines changed
Expand file tree Collapse file tree 6 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export interface ReactGoogleAutocompleteProps {
99 inputAutocompleteValue ?: string ;
1010 options ?: google . maps . places . AutocompleteOptions ;
1111 apiKey ?: string ;
12+ language ?: string ;
1213}
1314
1415export interface ReactGoogleAutocompleteInputProps
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ function usePlacesWidget(props) {
4545 var event = ( 0 , _react . useRef ) ( null ) ;
4646 var autocompleteRef = ( 0 , _react . useRef ) ( null ) ;
4747 var observerHack = ( 0 , _react . useRef ) ( null ) ;
48- var languageQueryParam = language ? "&language=" . concat ( language ) : '' ;
48+ var languageQueryParam = language ? "&language=" . concat ( language ) : "" ;
4949 var googleMapsScriptUrl = "" . concat ( googleMapsScriptBaseUrl , "?libraries=places&key=" ) . concat ( apiKey ) . concat ( languageQueryParam ) ;
5050 var handleLoadScript = ( 0 , _react . useCallback ) ( function ( ) {
5151 return ( 0 , _utils . loadGoogleMapScript ) ( googleMapsScriptBaseUrl , googleMapsScriptUrl ) ;
Original file line number Diff line number Diff line change @@ -9,6 +9,11 @@ exports.isBrowser = isBrowser;
99
1010var loadGoogleMapScript = function loadGoogleMapScript ( googleMapsScriptBaseUrl , googleMapsScriptUrl ) {
1111 if ( ! isBrowser ) return Promise . resolve ( ) ;
12+
13+ if ( typeof google !== "undefined" ) {
14+ if ( google . maps && google . maps . api ) return Promise . resolve ( ) ;
15+ }
16+
1217 var scriptElements = document . querySelectorAll ( "script[src*=\"" . concat ( googleMapsScriptBaseUrl , "\"" ) ) ;
1318
1419 if ( scriptElements && scriptElements . length ) {
Original file line number Diff line number Diff line change 11{
22 "name" : " react-google-autocomplete" ,
3- "version" : " 2.3.0 " ,
3+ "version" : " 2.3.1 " ,
44 "description" : " React component for google autocomplete." ,
55 "main" : " index.js" ,
66 "types" : " index.d.ts" ,
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export default function usePlacesWidget(props) {
2828 const event = useRef ( null ) ;
2929 const autocompleteRef = useRef ( null ) ;
3030 const observerHack = useRef ( null ) ;
31- const languageQueryParam = language ? `&language=${ language } ` : '' ;
31+ const languageQueryParam = language ? `&language=${ language } ` : "" ;
3232 const googleMapsScriptUrl = `${ googleMapsScriptBaseUrl } ?libraries=places&key=${ apiKey } ${ languageQueryParam } ` ;
3333
3434 const handleLoadScript = useCallback (
Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ export const loadGoogleMapScript = (
66) => {
77 if ( ! isBrowser ) return Promise . resolve ( ) ;
88
9+ if ( typeof google !== "undefined" ) {
10+ if ( google . maps && google . maps . api ) return Promise . resolve ( ) ;
11+ }
12+
913 const scriptElements = document . querySelectorAll (
1014 `script[src*="${ googleMapsScriptBaseUrl } "`
1115 ) ;
You can’t perform that action at this time.
0 commit comments