Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

google-location-autocomplete-react

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-location-autocomplete-react - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

38

dist/GoogleLocationAutocomplete.js

@@ -28,5 +28,4 @@ var __assign = (this && this.__assign) || function () {

var inputRef = useRef(null);
var autocompleteRef = useRef(null);
var loadScript = function () {
var url = "https://maps.googleapis.com/maps/api/js?key=".concat(apiKey, "&libraries=places");
var url = "https://maps.googleapis.com/maps/api/js?key=".concat(apiKey, "&libraries=places&callback=initAutocomplete");
if (!document.querySelector("script[src=\"".concat(url, "\"]"))) {

@@ -38,28 +37,23 @@ var script = document.createElement("script");

document.head.appendChild(script);
script.onload = function () { return initializeAutocomplete(); };
}
};
var initializeAutocomplete = function () {
var _a;
if (inputRef.current && window.google && !autocompleteRef.current) {
autocompleteRef.current = new window.google.maps.places.Autocomplete(inputRef.current);
(_a = autocompleteRef.current) === null || _a === void 0 ? void 0 : _a.addListener("place_changed", function () {
var _a;
var place = (_a = autocompleteRef.current) === null || _a === void 0 ? void 0 : _a.getPlace();
if (onPlaceSelected && place) {
onPlaceSelected(place);
}
});
}
};
useEffect(function () {
window.initAutocomplete = function () {
if (inputRef.current && window.google) {
var autocomplete_1 = new window.google.maps.places.Autocomplete(inputRef.current);
autocomplete_1.addListener("place_changed", function () {
var place = autocomplete_1.getPlace();
if (onPlaceSelected) {
onPlaceSelected(place);
}
});
}
};
loadScript();
}, [apiKey]);
useEffect(function () {
if (inputRef.current && !autocompleteRef.current) {
initializeAutocomplete();
}
}, [initializeAutocomplete]);
return function () {
delete window.initAutocomplete;
};
}, [apiKey, onPlaceSelected]);
return _jsx("input", __assign({ ref: inputRef, type: "text" }, props));
};
export default GoogleLocationAutocomplete;
{
"name": "google-location-autocomplete-react",
"version": "1.0.5",
"version": "1.0.6",
"main": "dist/GoogleLocationAutocomplete.js",

@@ -5,0 +5,0 @@ "types": "dist/GoogleLocationAutocomplete.d.ts",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc