Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6290

How to clear input search text after searching an address using react-native-google-places-autocomplete

$
0
0

i need assistance with clearing the input box after successfully searching an address on react native - react-native-google-places-autocomplete.

import React from "react";import { View, StyleSheet } from "react-native";import { GooglePlacesAutocomplete } from "react-native-google-places-autocomplete";import { GOOGLE_API_KEY } from "../../environments";import Geocoder from "react-native-geocoding";import CurrentLocationButton from "./ResetLocationButton";import LoginButton from "./LoginButton";Geocoder.init(GOOGLE_API_KEY);const PlaceSearch = ({ stateObj, navigation }) => {  const { setLocation, currentLocation } = stateObj;  const onPressHandler = (data, details = null) => {    Geocoder.from(data.description).then((json) => {      console.log(json)      const newLocation = json.results[0].geometry.location;      const newLocationObj = {        latitude: newLocation ? newLocation.lat! : 0,        longitude: newLocation ? newLocation.lng! : 0,      };      setLocation(newLocationObj);    });  };  return (<><View style={styles.headerContainer}><View style={styles.searchContainer}><GooglePlacesAutocomplete            placeholder="Enter Location"            onPress={onPressHandler}            query={{              key: GOOGLE_API_KEY,              language: "en",            }}            styles={{              listView: {                width: 368,                marginTop: 3,              },            }}          /></View></View><View style={styles.buttonsContainer}><View style={styles.buttons}><CurrentLocationButton            currentLocation={currentLocation}            setLocation={setLocation}          /></View><View style={styles.space} /><View style={styles.buttons}><LoginButton navigation={navigation} /></View></View></>  );};

Much appreciated! :D

Ive looked all over google, stackoverflow and youtube however i am still yet to find the solution.


Viewing all articles
Browse latest Browse all 6290

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>