不受控制的 Popover Reactstrap 更新状态

问题描述 投票:0回答:1

这里我使用的是reactstarp的不受控制的弹出窗口,我有类别列表,并且有一个编辑按钮选项,所以当我单击编辑按钮图标时,不受控制的弹出窗口似乎是正确的,但现在的情况就像当我单击它打开的类别下面时一样弹出窗口在第一个位置打开,当我再次单击时,它完全按照我的需要可见。 我做了这样的事情:

<span
 className="material-icons-outlined icon icon-fs-16 text-primary cursor-pointer mr-6px"
 id={`add-edit-category-subcategory_${category.id}`}
 onClick={() => {
 this.changestatesStatus(
 category,
 `add-edit-category-subcategory_${category.id}`
 );  }}
 >
 edit
 </span>
<UncontrolledPopover
 className="custom-popover subcategory-popover"
 placement="right"
 trigger="legacy"
 isOpen={this.state.showPopover}
 target={this.state?.popoverId}
>

changestatesStatus = (category, id) => {
    console.log("id: ", id);
    this.setState(
      {
        showPopover: true,
        isEdit: true,
        category: category,
        popoverId: id,
      },
reactjs popover react-state
1个回答
0
投票

我通过检查 showPopover 在条件下是否正确解决了这个问题

{this.state.showPopover && (

© www.soinside.com 2019 - 2024. All rights reserved.