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.3 to 1.0.4

45

dist/GoogleLocationAutocomplete.js

@@ -24,10 +24,19 @@ var __assign = (this && this.__assign) || function () {

import { jsx as _jsx } from "react/jsx-runtime";
import { useEffect, useRef } from "react";
import { useCallback, useEffect, useRef } from "react";
var GoogleLocationAutocomplete = function (_a) {
var apiKey = _a.apiKey, onPlaceSelected = _a.onPlaceSelected, props = __rest(_a, ["apiKey", "onPlaceSelected"]);
var inputRef = useRef(null);
var handlePlaceSelect = function () {
if (inputRef.current) {
var loadScript = function (url) {
if (!document.querySelector("script[src=\"".concat(url, "\"]"))) {
var script = document.createElement("script");
script.src = url;
script.async = true;
script.defer = true;
document.head.appendChild(script);
}
};
var initializeAutocomplete = useCallback(function () {
if (inputRef.current && window.google) {
var autocomplete_1 = new window.google.maps.places.Autocomplete(inputRef.current);
autocomplete_1.addListener('place_changed', function () {
autocomplete_1.addListener("place_changed", function () {
var place = autocomplete_1.getPlace();

@@ -39,23 +48,23 @@ if (onPlaceSelected) {

}
};
}, [onPlaceSelected]);
useEffect(function () {
if (window.google && window.initAutocomplete) {
window.initAutocomplete();
return;
}
window.initAutocomplete = handlePlaceSelect;
window.initAutocomplete = initializeAutocomplete;
var url = "https://maps.googleapis.com/maps/api/js?key=".concat(apiKey, "&libraries=places&callback=initAutocomplete");
if (!document.querySelector("script[src=\"".concat(url, "\"]"))) {
var script = document.createElement("script");
script.src = url;
script.async = true;
script.defer = true;
document.head.appendChild(script);
}
loadScript(url);
return function () {
delete window.initAutocomplete;
};
}, [apiKey, onPlaceSelected]);
}, [apiKey, initializeAutocomplete]);
useEffect(function () {
var handleFocus = function () {
initializeAutocomplete();
};
var input = inputRef.current;
input === null || input === void 0 ? void 0 : input.addEventListener("focus", handleFocus);
return function () {
input === null || input === void 0 ? void 0 : input.removeEventListener("focus", handleFocus);
};
}, [initializeAutocomplete]);
return _jsx("input", __assign({ ref: inputRef, type: "text" }, props));
};
export default GoogleLocationAutocomplete;

2

package.json
{
"name": "google-location-autocomplete-react",
"version": "1.0.3",
"version": "1.0.4",
"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