FaridSafi / react-native-google-places-autocomplete

Customizable Google Places autocomplete component for iOS and Android React-Native apps
MIT License
2.01k stars 852 forks source link

Bug Report - Debounce is just delaying requests, not really debouncing them #918

Open iuricernov opened 11 months ago

iuricernov commented 11 months ago

Describe the bug

The debounce feature is just delaying the execution of the request code, and not eliminating the unnecessary requests.

For example, if I set a debounce interval and type "Los Angeles" quick enough on the field, it is doing 11 requests ("L", "Lo", "Los", ..., "Los Angeles") after an interval. The expected behavior for a debounced operation would be to do only one request ("Los Angeles") after the interval.

Reproduction - (required - issue will be closed without this)

To reproduce:

Additional context

If you are using expo please indicate here:

Fix

This is happening because we are calling _.debounce many times with different contexts. I fixed it using setTimeout on my own fork: https://github.com/iuricernov/react-native-google-places-autocomplete/tree/debounce-fix

The diff that fixes the issue: https://github.com/FaridSafi/react-native-google-places-autocomplete/compare/master...iuricernov:react-native-google-places-autocomplete:debounce-fix

FacundoLastra commented 11 months ago

hi! i tested the fix, and work fine! thanks!

luannt102 commented 7 months ago

Thanks @iuricernov This fix is ​​working fine.

alianza commented 4 months ago

Thanks @iuricernov. I don't understand why this hasn't been fixed yet.