How get data from material-ui TextField, DropDownMenu components?

后端 未结 10 2013
遥遥无期
遥遥无期 2021-01-31 01:13

I create form, I have several TextField, DropDownMenu material-ui components included, question is how I can collect all data from all TextFields, DropDownMenus in one obj and s

10条回答
  •  终归单人心
    2021-01-31 02:04

    Faced to this issue after a long time since question asked here. when checking material-ui code I found it's now accessible through inputRef property.

    ...
     {this.myRefs.username = c}}
      label="Username"
      placeholder="xxxxxxx"
      margin="normal"
      className={classes.textField}
      variant="outlined"
      fullWidth
    />
    ...
    

    Then Access value like this.

      onSaveUser = () => {
        console.log('Saving user');
        console.log(this.myRefs.username.value);
      }
    

提交回复
热议问题