ErrorPro / react-google-autocomplete

React components for google places API.
MIT License
473 stars 114 forks source link

Not able to restrict the search suggestion to start after 3 characters. #166

Closed santhoshspecbee closed 1 year ago

santhoshspecbee commented 2 years ago

Need to show suggestion after 3 characters. Currently shows suggestion after typing a single character.

image

santhoshspecbee commented 2 years ago

@ErrorPro Please review.

andaden commented 2 years ago

@santhoshspecbee Could you please try using debounce prop?

prabhakaran8737 commented 1 year ago

@andaden any example on how to use debounce, I use something like this but doesn't work

<Autocomplete
    debounce='1000'
    onPlaceSelected={(data) => {
        this.handlePlaceChange(data);
    }}
/>
AlexeyRDKV commented 1 year ago

You can use debounce with usePlacesAutocompleteService here is an example.

const {
    placesService,
    placePredictions,
    getPlacePredictions,
    isPlacePredictionsLoading
  } = usePlacesService({
    apiKey: process.env.REACT_APP_GOOGLE,
    debounce: 1500
  });

You can leave a message here suggesting what you would like to add to ErrorPro/react-google-autocomplete