I have component in React-Native:
<View style={{ flexDirection: "column", justifyContent: "space-around", width: "100%", marginTop: 30 }}>
<MeasurementValues />
</View>
with function :
const list = [{"name": "field1"}, {"name": "field2"}, {"name": "field3"}];
const changeValue = (field, text) => {
console.log(field + " => " + text);
};
const MeasurementValues = () => {
var values = [];
for (var key in list) {
values.push(<TextInput placeholder={list[key].name} keyboardType="numeric" onChangeText={(text) => changeValue(list[key].name.toString(), text)} />)
}
return <>{values}</>
}
and when I enter something in all fields, I always get "field3" as field variable in console.log.
placeholder is ok. Has field1,field2 and field3 value. Only onChangeText get field3 as value.
What I'm doing wrong? Thank you