Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

react-google-autocomplete

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-google-autocomplete

React component for google autocomplete.

Source
npmnpm
Version
1.0.17
Version published
Weekly downloads
149K
-19.07%
Maintainers
1
Weekly downloads
 
Created
Source

React google autocomplete

This is a simple react component for working with google autocomplete

Install

npm i react-google-autocomplete --save

You also have to include google autocomplete link api in your app. Somewhere in index.html or somwehrer else.

  <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=[YOUR_API_KEY]&libraries=places"></script>

Example

import Autocomplete from 'react-google-autocomplete';

<Autocomplete
    style={{width: '90%'}}
    onPlaceSelected={(place) => {
      console.log(place);
    }}
    types={['(regions)']}
    componentRestrictions={{country: "ru"}}
/>

The component has one function called onPlaceSelected. The function gets invoked every time a user chooses location. A types props means type of places in google place API. By default it uses (cities). A componentRestrictions prop by default is empty. A bounds prop by default is empty. You also can pass any props you want to the final input.

Contribution

If you would like to see something in this library please create an issue and I will implement it as soon as possible.

Keywords

react

FAQs

Package last updated on 31 Oct 2018

Did you know?

Socket

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.

Install

Related posts