Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

486
Views
¿Cómo hacer TextInput con menú desplegable/selector en react-native?

Necesito hacer una entrada de texto que muestre una lista de elementos tan pronto como empieces a escribir. Y solo esos elementos (en la lista) se pueden seleccionar como la opción de entrada. Intenté usar el componente selector, pero necesito agregar una función en la que el usuario pueda escribir y los elementos relacionados se mostrarán en el menú desplegable/selector y luego el usuario podrá seleccionar uno de ellos como opción.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Si quieres hacerlo con tu propio diseño personalizado, ve con algo como esto:

 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} />

Dentro de su método filterBanks, puede actualizar filterBankList, de modo que la lista plana se actualice con el nombre del banco.

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

Dentro de su onBankSelected (al que llama cuando ha seleccionado una de las opciones), simplemente configure el nombre del banco y vacíe la lista de filtros.

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

Y si quiere usar alguna biblioteca para evitar esto, puede ir con react-native-searchable-dropdown

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!