简体   繁体   中英

How to get focus from click event of a text to googleplaces autocomplete input?

need your help for an app iam trying to develop. So I have used react native googleautoplaces complete for the location, which is shown in the first text input.

The page when loaded gets the current location based on geocoder, geolocation codes i have used.

What i need is that, when i click on the 'change' link, it should focus or select the location input. page design , code for google autocomplete , code2 .

If i use ref, can i do like that. If yes, how to add multiple ref, because already another ref is used in the autocomplete. ref method used inside autocomplete, which takes the address value.

<GooglePlacesAutocomplete 
...
ref={(ref) => { this.ref_location = ref }

//your element where the "Change" is being pressed. I used a button just as an example

<Button
    title="Change"
    onPress={() => { this.ref_location.focus(); }}
/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM