
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
location-autocomplete
Advanced tools
React location field component, wired with Google's API for autocomplete functionality.
LocationAutocomplete is a tested React component that introduces an input field with autocomplete functionality. It leverages the Google Places API to provide a typeahead effect with address predictions, based on your established criteria.
You have included the Google Maps API multiple times on this page. This may cause unexpected errors.
Install the package:
$ npm install location-autocomplete --save
At the top of your .jsx
file, import the component:
import LocationAutocomplete from 'location-autocomplete';
Instantiate your component and set the properties that fit your needs:
<LocationAutocomplete
name="venue"
placeholder="Venue Name"
targetArea="New York, NY"
locationType="(regions)"
googleAPIKey="yourApiKey"
onChange={() => {}}
onDropdownSelect={() => {}}
/>
googleAPIKey
OR googlePlacesLibraryURL
-- Only ONE of these is required for autocomplete functionality.
onChange
-- function to handle field changes. This will fire on each key strike.
onDropdownSelect
-- function to handle selection of dropdown option. This will fire when the user clicks on one of the locations on the dropdown. You can use this function to handle updates of multiple fields.
onDropdownSelect(component) {
// this will give you access to the entire location object, including
// the `place_id` and `address_components`
const place = component.autocomplete.getPlace();
// this will return a reference to the input field
const inputField = component.input;
// other awesome stuff
}
Visit Google's API documentation to get your Google API key.
Any attribute that's normally accepted on an input field (e.g. name
, disabled
, etc.).
targetArea
-- "City, State" to bias results to a specific geographic location. If this value is not set, the component will bias results by current location. Note: Biasing results does not restrict. See componentRestrictions
if you would like to return results only from a specific region.
locationType
-- String value used to restrict results to a specific location type. For a complete list of supported types, visit Google's API documentation. When not set, the component will include all location types.
componentRestrictions -- filter results by up to five countries. Countries must be passed as as a two-character, ISO 3166-1 Alpha-2 compatible country code. Multiple countries must be passed as a list of country codes: componentRestrictions={{ country: ['it'] }}
<!-- location-field.jsx -->
import React from 'react';
import LocationAutocomplete from 'location-autocomplete';
const LocationField = props => (
<LocationAutocomplete
onChange={() => {}}
onDropdownSelect={() => {}}
googleAPIKey={GOOGLE_API_KEY}
className="location"
{...props}
/>
);
export default LocationField;
<!-- registration-form.jsx -->
import React from 'react';
import LocationField from 'src/location-field.jsx';
<!-- ... -->
<LocationField
componentRestrictions={{ country: ['us', 'pr'] }}
locationType="establishments"
/>
<!-- ... -->
Install dependencies:
$ npm install
Run tests in watch mode:
$ npm run test:watch
Run the linter:
$ npm run lint
Start the server:
$ npm run bundle && npm run serve
Don't forget the following commands before committing!
$ npm run test
$ npm run lint:test
$ npm run lint
$ npm run build
Recommended commit format:
Commit title
<What does this commit introduce?>
References:
<Issue number>
FAQs
React location field component, wired with Google's API for autocomplete functionality.
The npm package location-autocomplete receives a total of 19 weekly downloads. As such, location-autocomplete popularity was classified as not popular.
We found that location-autocomplete demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.