File tree Expand file tree Collapse file tree 5 files changed +19
-6
lines changed
Expand file tree Collapse file tree 5 files changed +19
-6
lines changed Original file line number Diff line number Diff line change 1+ ![ ] ( /docs/example.gif )
2+
13![ ] ( https://img.badgesize.io/ErrorPro/react-google-autocomplete/master/lib/index.js?compression=gzip&label=gzip )
24![ ] ( https://img.badgesize.io/ErrorPro/react-google-autocomplete/master/lib/index.js?compression=brotli&label=brotli )
5+ ![ ] ( https://badgen.net/npm/dm/react-google-autocomplete?labelColor=49516F&color=8994BC )
36[ ![ GitHub license] ( https://img.shields.io/github/license/Naereen/StrapDown.js.svg )] ( https://GitHub.com/ErrorPro/react-google-autocomplete/master/LICENSE )
47
58## React google autocomplete
@@ -130,9 +133,7 @@ const AutocompleteTS: FC<ReactGoogleAutocomplete> = Autocomplete as FC<ReactGoog
130133< AutocompleteTS apiKey = " 123" / > ;
131134```
132135
133- ### More examples(dynamic props, MaterialUI) how to use the lib could be found in ` examples/index.js `
134-
135- [ Video of the example] ( https://api.monosnap.com/file/download?id=vIjRwTxVyMj0Sd2Gjhsfie2SPk1y4l )
136+ More examples(dynamic props, MaterialUI) how to use the lib could be found in ` docs/examples.js `
136137
137138### TODO
138139
File renamed without changes.
Original file line number Diff line number Diff line change @@ -60,6 +60,10 @@ function ReactGoogleAutocomplete(props) {
6060
6161 if ( scriptElement ) {
6262 return new Promise ( function ( resolve ) {
63+ // in case we already have a script on the page and it's loaded we resolve
64+ if ( typeof google !== "undefined" ) return resolve ( ) ;
65+
66+ // otherwise we wait until it's loaded and resolve
6367 scriptElement . addEventListener ( "load" , function ( ) {
6468 return resolve ( ) ;
6569 } ) ;
@@ -165,9 +169,11 @@ ReactGoogleAutocomplete.propTypes = {
165169 ref : _propTypes2 . default . oneOfType ( [
166170 // Either a function
167171 _propTypes2 . default . func ,
168- // Or the instance of a DOM native element (see the note about SSR)
172+ // Or the instance of a DOM native element
169173 _propTypes2 . default . shape ( { current : _propTypes2 . default . instanceOf ( Element ) } ) ] ) ,
170- autocompleteRef : _propTypes2 . default . oneOfType ( [ _propTypes2 . default . func , _propTypes2 . default . shape ( { current : _propTypes2 . default . instanceOf ( Element ) } ) ] ) ,
174+ autocompleteRef : _propTypes2 . default . oneOfType ( [ _propTypes2 . default . func , _propTypes2 . default . shape ( {
175+ current : _propTypes2 . default . any
176+ } ) ] ) ,
171177 googleMapsScriptBaseUrl : _propTypes2 . default . string ,
172178 onPlaceSelected : _propTypes2 . default . func ,
173179 inputAutocompleteValue : _propTypes2 . default . string ,
Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ function ReactGoogleAutocomplete(props) {
4242
4343 if ( scriptElement ) {
4444 return new Promise ( ( resolve ) => {
45+ // in case we already have a script on the page and it's loaded we resolve
46+ if ( typeof google !== "undefined" ) return resolve ( ) ;
47+
48+ // otherwise we wait until it's loaded and resolve
4549 scriptElement . addEventListener ( "load" , ( ) => resolve ( ) ) ;
4650 } ) ;
4751 }
@@ -165,7 +169,9 @@ ReactGoogleAutocomplete.propTypes = {
165169 ] ) ,
166170 autocompleteRef : PropTypes . oneOfType ( [
167171 PropTypes . func ,
168- PropTypes . shape ( { current : PropTypes . instanceOf ( Element ) } ) ,
172+ PropTypes . shape ( {
173+ current : PropTypes . any ,
174+ } ) ,
169175 ] ) ,
170176 googleMapsScriptBaseUrl : PropTypes . string ,
171177 onPlaceSelected : PropTypes . func ,
You can’t perform that action at this time.
0 commit comments