Home > database >  how to create ref for Autocomplete component from react-native-autocomplete-input for make it focus?
how to create ref for Autocomplete component from react-native-autocomplete-input for make it focus?

Time:01-13

how to create ref with Autocomplete component react-native-autocomplete-input for focus function ?

so i have this code

<View 
           onTouchEndCapture={() => {this.inputCity.focus()}}>

                <Autocomplete
                    ref={inputCity => this.inputCity = inputCity}
                    
                />
            </View>

how to make autocomplete component focus when user trigger from view component?

CodePudding user response:

I think instead of using View and onTouchEndCapture, use TouchableOpacity and onPress function may focus Autocomplete

<TouchableOpacity
   onPress={()=>this.inputCity.focus()}>
    <Autocomplete
      ref={inputCity => this.inputCity = inputCity}/>
</TouchableOpacity>
  •  Tags:  
  • Related