React Google Places Text Search
A Fork from tintef/react-google-places-autocomplete, enhanced to filter by types with an extra feature, GooglePlacesGetDetails
.
Getting started
Install the latest version:
npm install --save @bhl09/react-google-places-text-search
or
yarn add @bhl09/react-google-places-text-search
Autocomplete with type filtering
import React from 'react';
import GooglePlacesAutocomplete from 'react-google-places-autocomplete';
const Component = () => (
<div>
<GooglePlacesAutocomplete
apiKey="****"
types={['gas_station','supermarket','home_goods_store']}
enableResultLog={true} // Enabling this will log the results to console
/>
</div>
);
export default Component;
Get details
import React from 'react';
import { GooglePlacesGetDetails } from 'react-google-places-autocomplete';
const Component = () => {
const getDetails = async () => {
await GooglePlacesGetDetails(apiKey, placeId, (result) => {
console.log(result);
});
}
};
export default Component;
Original
import React from 'react';
import GooglePlacesAutocomplete from 'react-google-places-autocomplete';
const Component = () => (
<div>
<GooglePlacesAutocomplete
apiKey="****"
/>
</div>
);
export default Component;
Coming from v2? Check the migration guide
Documentation
How to contribute?
-
Fork this repo
-
Clone your fork
-
Code
🤓 -
Test your changes
For this, I like to use yalc, as it allows to emulate the process of using npm/yarn.
- Install yalc
- Build project with
yarn build
ornpm run build
- Publish the package with yalc:
yalc publish
- Add the package to your test project
yalc add react-google-places-automocomplete
- If needed, to update the package on your test project:
yalc update react-google-places-autocomplete
-
Submit a PR!
Icons made by Freepik from www.flaticon.com