react-native-google-autocomplete icon indicating copy to clipboard operation
react-native-google-autocomplete copied to clipboard

inputValue always lags behind 1

Open karimcambridge opened this issue 5 years ago • 2 comments

Can this be corrected? The passed argument is always the last value and not the current value.

karimcambridge avatar Mar 17 '20 07:03 karimcambridge

Should be the current value. Let me check

EQuimper avatar Mar 17 '20 13:03 EQuimper

inputValue: inputValue: f inputValue: fr

image

return (
    <GoogleAutoComplete
      apiKey={GOOGLE_API_KEY_PLACES}
      debounce={300}
      minLength={data.maxTextSearchLength}
      components={`country:${country.toLowerCase()}`}
      radius={`${radius}`}
      lat={location.latitude}
      lng={location.longitude}
      queryTypes={''}
    >
      {({ inputValue, handleTextChange, locationResults, fetchDetails, isSearching }) => (
        <View
          style={{ ...styles.container, ...style }}>
          <React.Fragment>
            <View style={{ ...styles.textInputContainer, height: insets.top + 30 }}>
              <Searchbar
                placeholder='Find your destination'
                onChangeText={props => { handleTextChange(props); onSearchingUpdate(inputValue, isSearching); console.log(`inputValue: ${inputValue}`); }}
                value={inputValue}
                icon={isSearching ? () => (<ActivityIndicator animating={true} color={Colors.blueA700} />) : () => (<MaterialIcons name={iconName ? iconName : 'search'} size={24} color={iconColor ? iconColor : theme.colors.black} />)}
                onIconPress={isSearching ? null : onIconPress}
                onFocus={onFocus}
              />
            </View>
            {
              handleSearchingUpdate(inputValue, locationResults) && locationResults.length
            ?
                <ScrollView
                  style={styles.listView}
                  keyboardShouldPersistTaps='handled'
                >
                  <List.Section>
                    {locationResults.map((el, i) => (
                      <LocationItem
                        {...el}
                        fetchDetails={fetchDetails}
                        key={String(i)}
                      />
                    ))}
                  </List.Section>
                </ScrollView>
              :
                null
            }
          </React.Fragment>  
        </View>
      )}
    </GoogleAutoComplete>
  );
};

Or am I doing something wrong?

karimcambridge avatar Mar 17 '20 14:03 karimcambridge