M
M
Maksipes2020-01-09 19:11:21
React
Maksipes, 2020-01-09 19:11:21

How to know the state of a Select dropdown list?

Is it possible to know the state of the list - collapsed or opened in the following situation:

<Select
  value={this.state.value}
  onChange={this.handleChange}
>
  <MenuItem value="">
    // тут как-то надо проверить состояние списка
  </MenuItem>
  <MenuItem value={10}>Ten</MenuItem>
  <MenuItem value={20}>Twenty</MenuItem>
  <MenuItem value={30}>Thirty</MenuItem>
</Select>

It uses ReactJS and Material UI, the Select component.
Is there some way to check if the list is "open" or not, without passing an extra propsin from Select to MenuItem ?
Thank you in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osher, 2020-01-09
@miraage

I see two options:
1) control the open prop
2) throw onOpen / onClose and rely on this state in the local useState

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question