React-native-google-places-autocomplete: Clear the form

Created on 28 May 2017  路  9Comments  路  Source: FaridSafi/react-native-google-places-autocomplete

Is there a way to clear the input ? let say once I submitted the form I want to clear the input.

Most helpful comment

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.

All 9 comments

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)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GervaisYO picture GervaisYO  路  4Comments

mbelgrader picture mbelgrader  路  4Comments

sohel-tech picture sohel-tech  路  3Comments

DennisMuchiri picture DennisMuchiri  路  4Comments

KhalilKhalaf picture KhalilKhalaf  路  4Comments