I have to let user make a choice between products (p1, p2,...) with a react native picker (on android) and then he had to set quantity of chosen product with a TextInput, and then I have to show him after clicking Add button which product he chose, and after each Add click a new item of product and his quantity is shown :
I don't know how to set data (productId and quantity) in an array or JSON
this is a part of code:
constructor(props){
super(props)
this.state = {
valueP: '',
quantity: '',
}}
...
<View style={Styles.type12Container}>
<View style={Styles.inputContainer}>
<Picker
value={this.state.valueP}
style={Styles.picker}
mode= "dropdown"
prompt= "XXX"
selectedValue = {this.state.valueP}
onValueChange = {(val) => { this.setState({valueP: val}}}>
<Picker.Item label="P 1" value="1" />
<Picker.Item label="P 2" value="2"/>
<Picker.Item label="P 3" value="3" />
</Picker>
</View>
<View style={Styles.inputContainer}>
<TextInput
value={this.state.quantity}
style={Styles.inputStyle}
onChangeText={(val) => this.setState({quantity: val})}
/>
</View>
<View style={Styles.button1Container}>
<TouchableOpacity
onPress={this.addConv}
style={Styles.buttonAdd}>
<Text style={Styles.button1Text}>Add</Text>
</TouchableOpacity>
</View>
<View style={Styles.output}>
<View>
<Text style={Styles.button1Text}>products and quantity items</Text>
</View>
</View>
</View>
can you please suggest me a solution or a similar example
