Skip to content

Instantly share code, notes, and snippets.

@radzionc
Created August 2, 2018 17:50
Show Gist options
  • Save radzionc/e898dbb15a883f084acafeed71302761 to your computer and use it in GitHub Desktop.
Save radzionc/e898dbb15a883f084acafeed71302761 to your computer and use it in GitHub Desktop.
({ changeCityInputValue, cityInputValue, selectCity, city }) => (
<PlacesAutocomplete
highlightFirstSuggestion
value={cityInputValue}
onChange={changeCityInputValue}
onSelect={selectCity}
searchOptions={{ types: ['(cities)']}}
onError={() => changeCityInputValue('')}
>
{({ getInputProps, suggestions, getSuggestionItemProps, loading, ...rest }) => (
<Paper style={inputContainerStyle}>
<TextField
{...getInputProps({
placeholder: 'Search City ...',
})}
/>
<List>
{suggestions.map((suggestion) => (
<ListItem {...getSuggestionItemProps(suggestion)} key={suggestion.description} button>
<ListItemText primary={suggestion.description}/>
</ListItem>
))}
</List>
</Paper>
)}
</PlacesAutocomplete>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment