【发布时间】:2019-03-01 20:10:43
【问题描述】:
我们如何从动态创建的文本输入中访问值。像平面列表一样创建 3 个文本输入,然后单击按钮,我们验证添加了哪个,不添加了哪个。如何管理多个状态数组。目前我这样做了
const data = [1,2];
constructor(props) {
super(props);
this.state = {
Textdata:[],
};
}
SubmitButton(){
//how to access those text input values and add to array
}
<FlatList
data={data}
renderItem={this.renderItem}
keyExtractor={(item, index) => item}
/>
renderItem = ({ item, index }) => {
return (
<View>
<Item
floatingLabel
style={styles.InputBoxStyle}
>
<Label>First Name</Label>
<Input
/>
</Item>
<Item
floatingLabel
style={styles.InputBoxStyle}>
<Label>Last Name</Label>
<Input
/>
</Item>
<Button rounded
onPress={this.SubmitButton}>
<Text>Submit</Text>
</Button>
</View>
);
};
【问题讨论】:
标签: reactjs react-native react-native-android react-native-ios react-native-flatlist