diff --git a/GooglePlacesAutocomplete.d.ts b/GooglePlacesAutocomplete.d.ts index 15d5a8a0..b6b65c6a 100644 --- a/GooglePlacesAutocomplete.d.ts +++ b/GooglePlacesAutocomplete.d.ts @@ -378,6 +378,8 @@ interface GooglePlacesAutocompleteProps { enablePoweredByContainer?: boolean; fetchDetails?: boolean; /** filter the reverse geocoding results by types - ['locality', 'administrative_area_level_3'] if you want to display only cities */ + filter?: (data: any[]) => any[]; + /** add custom filter method for dataSource */ filterReverseGeocodingByTypes?: PlaceType[]; /** available options for GooglePlacesDetails API: https://developers.google.com/places/web-service/details */ GooglePlacesDetailsQuery?: Partial & { fields?: string }; diff --git a/GooglePlacesAutocomplete.js b/GooglePlacesAutocomplete.js index de3099a2..13cc1c4a 100644 --- a/GooglePlacesAutocomplete.js +++ b/GooglePlacesAutocomplete.js @@ -764,7 +764,7 @@ export const GooglePlacesAutocomplete = forwardRef((props, ref) => { props.suppressDefaultStyles ? {} : defaultStyles.listView, props.styles.listView, ]} - data={dataSource} + data={props.filter ? props.filter(dataSource): dataSource} keyExtractor={keyGenerator} extraData={[dataSource, props]} ItemSeparatorComponent={_renderSeparator}