Is there a way to clear the input ? let say once I submitted the form I want to clear the input.
I want this too
You can do this:
1) The component that you are using <ReactNativeGooglePlacesAutocomplete /> need to be a class component.
2) Then add a ref to the component like this <ReactNativeGooglePlacesAutocomplete ref={(instance) => { this.GooglePlacesRef = instance }}/>
3) When you need to clear the input just this.GooglePlacesRef.clearInput()
Thanks for the tip! This worked, but I had to do a this.GooglePlacesRef.setAddressText(""). There was no clearInput() in the react-native-google-places-autocomplete component.
@ujwal-setlur Maybe they changed the component methods, I tried this like 1 month ago. Glad it works 馃榾
@ujwal-setlur Maybe they changed the component methods, I tried this like 1 month ago. Glad it works 馃榾
i would like to ask where can i find a documentation where "setAddressText" can be found,
i cant find it here,
1)
2) At onPress use this.GooglePlacesRef.setAddressText("").
Work for me
Hello. How can we clear the results of the search? setAddressText("") only clear the textinput text only.
i got this.GooglePlacesRef is indefined how can i fix that anyone can help ?
i got this.GooglePlacesRef is indefined how can i fix that anyone can help ?
this.GooglePlacesAutocomplete use this instead, the named changed
In case this happens again just take a look at the source code of the component (GooglePlacesAutocomplete.js)
Most helpful comment
Thanks for the tip! This worked, but I had to do a
this.GooglePlacesRef.setAddressText(""). There was noclearInput()in the react-native-google-places-autocomplete component.