Bootstrap Dropdown not working in React

后端 未结 4 1511
野的像风
野的像风 2020-12-17 17:28

I\'m trying to get a dropdown working inside a form for one of my React components. Here is how I\'m setting up the dropdown portion of the code, the following is inside a f

4条回答
  •  忘掉有多难
    2020-12-17 18:23

    after a long searching and tweaking I got the answer here

    you just have to add a css to resolve this issue. when you click on dropdown button, it adds a class "show" to that element and as per bootstrap that much is sufficient to make a dropdown button work.

    .show>.dropdown-menu {
      display: block;
      position: absolute;
    }
    

    for me it work like charm.

    I tries @teimurjan solution and it worked for me but with two issues

    1. I have to manage a state even though its not needed
    2. once dropdown clicked the expanded menu does not disappear on click of body or anywhere else.

提交回复
热议问题