Сбросить поле выбора с помощью пользовательского интерфейса материала - PullRequest
0 голосов
/ 24 марта 2020

У меня есть простой компонент Select (не подключен) с пользовательским интерфейсом материала (https://material-ui.com/components/selects/).

Мне нужно сбросить поле, но я не могу найти как.

Есть идеи?

Спасибо!

Мой тест:

import React from "react";
import InputLabel from "@material-ui/core/InputLabel";
import MenuItem from "@material-ui/core/MenuItem";
import FormControl from "@material-ui/core/FormControl";
import Select from "@material-ui/core/Select";
import Button from "@material-ui/core/Button";

class Form extends React.Component {
  constructor(props) {
    super(props);
    this.selectRef = React.createRef();
  }

  handleClick() {
    this.selectRef.current.value = null
  }
  render() {
    return (
      <div>
        <FormControl>
          <InputLabel id="demo-simple-select-label">Age</InputLabel>
          <Select
            inputRef={this.selectRef}
            labelId="demo-simple-select-label"
            id="demo-simple-select"
          >
            <MenuItem value={10}>Tens</MenuItem>
            <MenuItem value={20}>Twenty</MenuItem>
            <MenuItem value={30}>Thirty</MenuItem>
          </Select>
          <Button onClick={this.handleClick.bind(this)}>Reset</Button>
        </FormControl>
      </div>
    );
  }
}
export default Form;
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...