反应:无法在“节点”上执行“ removeChild”:要删除的节点不是该节点的子节点

时间:2019-12-05 13:17:43

标签: javascript reactjs

我收到此错误“无法在'节点'上执行'removeChild':要删除的节点不是该节点的子节点。”。这是在我的第3到第4个下拉列表选择之后发生的。

我选择下拉菜单的前几次,表格显示得很好,不确定为什么在第3至4次间断地发生这种情况?!


下拉选择功能:

public handleDropdownChange(e) {

this.setState({ selectedOption: e.target.value });

{ setTimeout(() => {

  this.getDocuments();

}, 1000); }

{ setTimeout(() => {

  this.renderDocuments();

}, 2000); }

}

渲染文档功能:

 public renderDocuments() {

const docs = this.state.documents.map(document => {

  return (
    <tr>
      <td className="title">{document.Cells.results[3].Value }</td>
      <td className="site">{siteName}</td>
      <td className="path">{sitePath}</td>
      <td><a href={document.Cells.results[6].Value + '?web=1&action=edit'}>View File</a></td>
    </tr> 
  );

});

return (

  <div id="tableID" className="table-list-container">

    <table className="table-list">

      <thead>
        <th><button type="button" className="sort" data-sort="title">Title</button></th>
        <th><button type="button" className="sort" data-sort="site">Site</button></th>
        <th><button type="button" className="sort" data-sort="path">Path</button></th>
        <th><button type="button">View File</button></th>
      </thead>

      <tbody className="list">

        {docs}

      </tbody>

    </table>

    <table className="table-footer">
      <tr>
        <td className="table-pagination">
          <ul className="pagination"></ul>
        </td>
      </tr>
    </table>

  </div>

);

   }

渲染:

  public render(): React.ReactElement<IKimProps> {

    let { documents } = this.state;

    return (

      <div className={ styles.kim }>

        {"Display Items that are pending review by Favourite Colour:"}

        {documents.length === 0 && <p>Loading...</p>}

        <select id="dropdown" onChange={this.handleDropdownChange}>
          <option value="N/A">N/A</option>
          <option value="red">Red</option>
          <option value="green">Green</option>
          <option value="blue">Blue</option>
        </select>

        <br/><br/>

        {this.renderDocuments()}

     </div>

    );
  }

}

1 个答案:

答案 0 :(得分:1)

是的,将JQuery和React一起使用可能会得到这些结果。有足够的React软件包,我建议改用其中一种。