Hello.
I’m currently trying to make my own board with some data that I fetch in my componentWillMount(), then, I store this data in a state. Until here, all is normal, I can display my data with some FlatList. But, in one of them, I use a TextInput to change a quantity value.
When the value is null, I can modify it without any problem. But, when there is a value (store with the fetch), I can’t modify it. When I try, the TextInput is replacing it by the default value. I don’t understand because in my onChangeText, I’m modifying the value in the array that I use.
Someone got an idea? Thanks ! (Sorry for my english
)
Here is my FlatList code :
<FlatList
data={state.tableData}
keyExtractor={item => item.product_id + ""}
renderItem={({ item, index }) =>
<View style={[styles.columnRow, {backgroundColor: "#dff2ff"}]}>
<TextInput
style={styles.textInput}
maxLength={10}
textAlign={'center'}
keyboardType={'numeric'}
returnKeyType="next"
blurOnSubmit={false}
onChangeText={text => {
let { tableData } = this.state;
let newQte = '';
let numbers = '0123456789';
for (var i=0; i < text.length; i++) {
if(numbers.indexOf(text[i]) > -1 ) {
newQte = newQte + text[i];
}
else {
alert("Veuillez saisir uniquement des chiffres.");
}
}
tableData[index].quantity = newQte;
this.setState({
tableData,
});
}}
value={item.quantity}
/>
</View>}
scrollEnabled={false}
/>