Is there any function to clear text input after a place has been selected? This seems like a base case where once the user has found the place they want the input clear to search again for another place.
Just wanted to mention that I am interested in the same thing. I posted an issue here with the same goal https://github.com/FaridSafi/react-native-google-places-autocomplete/issues/240
I also am wondering why this functionality doesn't exist. The 'x' on the right side of the search bar does nothing when pressed and it seems like this should cause the text input to be cleared.
@hammadzz @jmancherje @ConnorWhelan11 i have just commented out the line
// this.setState({
// text: this._renderDescription( rowData ),
// }); in the row data function. this was responsible for showing the selected location. Try out and let me know if it is the right way to do it! thanks
@hammadzz @jmancherje @ConnorWhelan11 @codenamev
any updates on the same...
im facing the same +1
@preyesm
i tried the same and it was not working for me
Not the best solution, but I am currently doing this:
<GooglePlacesAutocomplete
ref={c => this.googlePlacesAutocomplete = c} // set a reference for GooglePlacesAutocomplete
...
/>
and then:
this.googlePlacesAutocomplete._handleChangeText('') // use _handleChangeText to set the text that you want
@guilhermepontes where are we supposed to put this.googlePlacesAutocomplete._handleChangeText("")?
If you are still looking for a fix for this, my solution is doing this in the textInputProps props
const [location, setLocation] = useState({
destination: "",
});
textInputProps={{
onChangeText: (text) => {
if (text === "") setLocation({ destination: "" });
}
Most helpful comment
Not the best solution, but I am currently doing this:
and then: