score:2

Accepted answer

You're not storing the selected value in your state, and the name in inputProps is hard coded to 'age'. If you fix those problems, it works:

      <Select
        value={this.state[val.name] ? this.state[val.name] : ''}
        onChange={this.handleChange}
        inputProps={{name: val.name}}
      >

Here's a CodeSandbox link.

UPDATE: The undefined values cause the label to overlap with the selected value, and since you retrieve them dynamically and cannot initialize them in the state, you can use a conditional this.state[val.name] ? this.state[val.name] : '' to fix the labels. (sandbox has been updated)


Related Query

More Query from same tag