TextInput inside FlatList based on API response.
See original GitHub issueHi, 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
- 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:-
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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:
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.