Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

488
Visualizações
how to make TextInput with dropdown/picker in react-native?

I need to make a text input that shows a list of items as soon as you start typing. And only those items(in the list) can be selected as the option for input. I tried using the picker component but I need to add a feature where the user can type and items related to it will be shown in the dropdown/picker and then the user will be able to select one of them as the option.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you want to make it with your own custom design, then go with something like this:

  const [filterBankList, setFilterBankList] = useState([]);
  const [bankName, setBankName] = useState('');


            <TextInput
                  value={bankName}
                  placeholder={strings.selectBankName}
                  style = {styles.textInput}
                  onChangeText={filterBanks}
                />
                <FlatList
                  data={filterBankList}
                  renderItem={({item, index}) => (
                    <TouchableOpacity
                      onPress={() => onBankSelected(item?.bank)}>
                      <VariantsBox>
                        <Text
                          >
                          {item?.bank || ''}
                        </Text>
                      </VariantsBox>
                    </TouchableOpacity>
                  )}
                  keyExtractor={item => item.bank}
                />

Inside your filterBanks method, you can update the filterBankList, so that the flatlist is updated with the bank name.

const filterBanks = value => {
    
    let filterData =
      bankList && bankList?.length > 0
        ? bankList?.filter(data =>
            data?.bank?.toLowerCase()?.includes(value?.toLowerCase()),
          )
        : [];
    setFilterBankList([...filterData]);
  };

Inside your onBankSelected(which you call when you have selected one of the options), then just set the bankName and empty the filterlist.

const onBankSelected = value => {
    setBankName(value);
    setFilterBankList([]);
  };

And if you want to use some library to avoid this, you can then go with react-native-searchable-dropdown

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda