Wednesday, April 5, 2017

Dynamic dropdown list in reactJs

type="vertical"
control="select"
id="number-of-devices"
label="Number of devices"
required={true}
value={this.state.devices}
onChange={e => this.setState({devices: e.target.value})}
options={this.getDevices()}
/>

getDevices() {
let i = 0;
let devices = [];
while (i <= this.props.pay.number_of_devices) {
   devices.push({label: i, value: i})
   i++;
}
return devices;
}