N
N
Nikolay Semenov2017-10-03 14:10:56
JavaScript
Nikolay Semenov, 2017-10-03 14:10:56

How is dropdown-menu implemented in react?

Hello!
Guys tell me how to implement the appearance and hiding of the drop-down context menu on click in react?
in vue it was possible to change it to true on click and add a class if true.
I mean, in applications on frameworks, it seems like it’s not kamilfo to use the queriselector and others like them

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrei Smirnov, 2017-10-03
@pinebit

If you are planning to write your own component, then I highly recommend that you look at least at the API of other well-known implementations. For example semantic: https://react.semantic-ui.com/modules/dropdown
There are also examples. You can see what is happening under the hood in devtools and sources on github - this is Open Source.

V
Vit, 2017-10-03
@fornit1917

What's the problem?
Add the isVisible flag to the state of the component.
In the render method, depending on its value, render or not render the dropdown menu.
If you need to show it - do setState({ isVisible: true }), if you need to hide it - setState({ isVisible: false })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question