Answer the question
In order to leave comments, you need to log in
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
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.
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 questionAsk a Question
731 491 924 answers to any question