Skip to content
This repository was archived by the owner on Aug 29, 2020. It is now read-only.

Add automplete 'components' parameter #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ interface GoogleProps {
radius?: number
strictbounds?: boolean
offset?: number
components?: string
}

export interface AutocompleteProps {
Expand Down
3 changes: 2 additions & 1 deletion lib/use-google-autocomplete.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/use-google-autocomplete.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
"devDependencies": {
"@types/node": "^11.10.5",
"@types/react": "^16.8.6",
"@types/react-dom": "^16.8.2"
"@types/react-dom": "^16.8.2",
"typescript": "^3.5.2"
},
"scripts": {
"build": "rm -rf ./lib && tsc",
"build": "rm -rf ./lib && npx tsc",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
Expand Down
3 changes: 2 additions & 1 deletion src/use-google-autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ export default function useGoogleAutocomplete({
const language = options.language ? `&language=${options.language}` : ''
const location = options.location ? `&location=${options.location}` : ''
const radius = options.radius ? `&radius=${options.radius}` : ''
const components = options.components ? `&components=${options.components}` : ''

const url = `${cors}https://maps.googleapis.com/maps/api/place/autocomplete/json?input=${query}${types}${language}${location}${radius}${strictbounds}${offset}&key=${apiKey}&sessiontoken=${
const url = `${cors}https://maps.googleapis.com/maps/api/place/autocomplete/json?input=${query}${types}${language}${location}${radius}${components}${strictbounds}${offset}&key=${apiKey}&sessiontoken=${
sessionToken.current
}`

Expand Down