react-native-google-places-autocomplete icon indicating copy to clipboard operation
react-native-google-places-autocomplete copied to clipboard

Bug Report - App gets Crash while searching the location !!!

Open Hassaan0 opened this issue 1 year ago • 6 comments

Description

When users perform multiple rapid taps on the search bar in the app, it causes the app to crash. The issue occurs specifically when searching for locations, such as "IV George Avenue, Paris, France," and is triggered by aggressive interaction with the search function. This issue results in errors related to the GooglePlaceAutocomplete.js file. Specifically, it returns the error "Request has not been opened" and occasionally throws a "Cannot read property 'length' of undefined" error.

Reproduction

  • Open the app.
  • Navigate to the search bar.
  • Tap on the search bar repeatedly and rapidly (multiple times in quick succession).
  • Enter a location such as "IV George Avenue, Paris, France" and initiate the search.
  • Observe that the app crashes after several rapid taps.
  • Observe that the app crashes, and check the error messages:
    • Request has not been opened" at GooglePlaceAutocomplete.js (line: 339, 501, 570)
    • Cannot read property 'length' of undefined" (error may vary)

**Example of Code. **

Click to expand!
  <GooglePlacesAutocomplete
ref={ref}
disableScroll
query={{
  key: "MY_API_KEY",
  language: "en",
}}
minLength={2} 
listViewDisplayed="auto"
fetchDetails={true}
enableHighAccuracyLocation
onPress={async (data, details = null) => {
  const loc = details?.geometry?.location;
  if (!loc) {
    return;
  }
  console.log(details);
}}
styles={{
  textInputContainer: {
    flexDirection: "row",
    borderWidth: 1,
    borderRadius: 16,
    marginBottom: 5,
  },
  textInput: {
    borderRadius: 16,
    fontSize: 16,
  },
  row: {
    gap: 16,
    height: 45,
    marginVertical: 1,
    borderRadius: 16,
    paddingHorizontal: 10,
  },
}}
textInputProps={{
  onBlur: (e) => {
    e.preventDefault();
    e.stopPropagation();
  },
  onPressIn: () => {
    setState({
      item_selected: false,
    });
  },
}}
keepResultsAfterBlur
nearbyPlacesAPI="GooglePlacesSearch"
GooglePlacesDetailsQuery={{
  fields: "formatted_address,geometry",
}}
keyboardShouldPersistTaps="handled" 
debounce={300}// debounce the requests in ms. Set to 0 to remove debounce. By default 0ms.
/>

Additional context

  • Library Version: ^2.5.6

  • React Native Version: 0.73.6

  • [Yes] iOS

  • [Yes] Android

** ERROR SCREENSHOT **

simulator_screenshot_907BFB7A-ACF3-4897-8320-B28D5A392B4E

Hassaan0 avatar Aug 12 '24 09:08 Hassaan0