React-table 点击单行高亮。禁用多个 select

React-table on click single row highlight. Disable multiple select

我正在研究 React-table 中的小功能添加、编辑、删除功能。 我的代码是 运行。 我的问题是,如果用户单击该行,它会同时获得 selected 如果您单击另一行,它会获得 selected,但它不会禁用先前的 selected 行.基本上,用户一次可以 select 一行。禁用多个 select.

此外,如果有人可以查看我的添加、更新、删除功能,那就太好了。方法对不对

Running Code

已修复

  getTrProps={(state, rowInfo) => {
        if (rowInfo && rowInfo.row) {
          return {
            onClick: e => {
              console.log("inside");

              if (rowInfo.index != this.state.rowEdit) {
                this.setState({
                  rowEdit: rowInfo.index,
                  selectedRowIndex: rowInfo.original,
                  selectionChanged: this.state.selectionChanged
                    ? false
                    : true
                });
              } else {
                this.setState({
                  rowEdit: null
                });
              }
              console.log(rowInfo.index);
              console.log(this.state.rowEdit);
            },
            style: {
              background:
                rowInfo.index === this.state.rowEdit ? "#00afec" : "white",
              color:
                rowInfo.index === this.state.rowEdit ? "white" : "black"
            }
          };
        } else {
          return {};
        }
      }}