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

114
Views
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 answers
Answer question

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 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!