React google autocomplete

This is a simple react component for working with google autocomplete.


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="[YOUR_API_KEY]&libraries=places"></script>


import Autocomplete from 'react-google-autocomplete';

    style={{width: '90%'}}
    onPlaceSelected={(place) => {
    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.