question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TextInput inside FlatList based on API response.

See original GitHub issue

Hi, i am displaying TextInputs inside FlatList based on API response. But in FlatList i have check-boxes, drop-downs and TextInputs. If i can check one item in array then it will add some objects (contains TextInputs) in array. When a value is entered on a particular TextInput it’s working fine but if uncheck that item i should remove some objects (contains TextInputs) in array. In this case i am facing an issue like after unchecking the check-box text-field (what i have entered value before) is appending to below TextInput.

React Native version:

“react-native”: “0.60.5”

Steps To Reproduce

  1. How can i append the values to text-input after changing their positions like when i add some objects and remove some objects
this.state = {
     textInputsValue: [],
   };
 onChangeText(text) {
   const { index, item } = this.props;
   const textInputsValue = [...this.state.textInputsValue];
   textInputsValue[index] = text;
   this.setState({
     textInputsValue
   });
 }
 <Mytextinput
                 placeholder="Enter Here"
                 value={this.state.textInputsValue[index]}
                 onChangeText={this.onChangeText}
                 onEndEditing={this.onEndEditingText}
                 onSubmitEditing={() => Keyboard.dismiss()}
               />

Describe what you expected to happen:

  • Text-input values should not append to another text-inputs when i add some objects or remove some objects in array.

Screenshot:-

ezgif com-video-to-gif

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
radko93commented, Oct 28, 2019

I cannot reopen because it’s not a react native issue. Please ask this question on Stackoverflow. I can only say that you can try:

<ScrollView>
{dynamicInputs.map(input =>
   (<TextInput />))}
</ScrollView>
0reactions
harikanammicommented, Oct 28, 2019

yes, i am using FlatList for rendering the Text-inputs. But i am displaying text-inputs based on API response. So it is a dynamic array. I am getting an issue in UI part. Please go through the above gif file.

I am adding some objects in an array and entered the values in text-inputs and remove that objects in an array. So that the input value is assigned to another object.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TextInput inside a FlatList - Stack Overflow
From the sample code below, the FlatList returns n-number of TextInput, when a value is entered on a particular TextInput it keeps re-rendering ......
Read more >
Using List Views - React Native
React Native provides a suite of components for presenting lists of data. Generally, you'll want to use either FlatList or SectionList.
Read more >
Displaying a List in React Native: Map Method or FlatList ...
In this article, I'll walk you through using two methods of listing data in a React Native app: displaying the list with map...
Read more >
Create a React Native search bar from scratch - LogRocket Blog
Learn how to create your own React Native search bar from scratch in this detailed, step-by-step tutorial.
Read more >
Add a Search Bar Using Hooks and FlatList in React Native
FlatList is a component of the React Native API that allows fetching and displaying large arrays of data. In this tutorial, we use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found