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

123
Visualizações
How to clear dynamically added TextInputs in react native

I'm having a bit of an issue resetting my TextInputs after submitting because they were added dynamically.

I currently have my js code like this

                    <FlatList
                      data={this.state.items}
                      keyExtractor={(item, index) => item.party_id}
                      renderItem={({item}) =>
                        <View style={styles.InputBox}>
                            <TouchableOpacity style={styles.InputPartyLabel}><Text>{item.party_name}</Text></TouchableOpacity>
                            <TextInput
                                ref={input => { this.textInput = input }}
                                style={styles.Input}
                                placeholder="Number of votes"
                                onChangeText={result => this.collateResults(item.party_name, result)}
                                placeholderTextColor="#bbb"
                                autoCapitalize='none'
                                underlineColorAndroid='transparent'
                              />
                        </View> } />

I added this ref={input => { this.textInput = input }} but it only clears the last one.

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

0

You need this.textInput to be an array. And then push to that array when setting the refs

<TextInput
                                ref={input => this.textInput.push(input)}
                                style={styles.Input}
                                placeholder="Number of votes"
                                onChangeText={result => this.collateResults(item.party_name, result)}
                                placeholderTextColor="#bbb"
                                autoCapitalize='none'
                                underlineColorAndroid='transparent'
                              />
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