Conflict occurs when expandedRowRender and onexpand,expandedRowKeys, are used at the same time?!

expandedRowRender, onexpand,expandedRowKeys, conflict when using at the same time?!
  • showListDom: stores unfold row data
  • expandedFunction: requests backend data
  • arr: holds the id array of the current row (only one item)
< hr >

within the render method:

<Table
    dataSource={this.state.SampleData}
    rowKey={record => record.id || record.key}
    columns={columns}
    onChange={this.handleStandardTableChange}
    pagination={this.state.pagination}
    loading={this.state.loading}
    expandedRowRender={(record) => { return this.state.showListDom[record.id] || null; }}
    onExpand={(expanded, record) => { return this.expandFunction(expanded, record) || null;}}
   expandedRowKeys={this.state.arr}//
  />

< hr >

error message:

clipboard.png

< hr >
what you want to achieve is that when you click a row, the other lines automatically shrink, expanding only one line at a time.
without expandedRowkeys, the effect can be achieved: when a row (a line) is expanded, click the "+" expander of another row (b line), and b line can get the data and expand it. At the same time, the data of row an is set to empty, but does not shrink (the expander is still "+", the empty table is shown below)
May.11,2021

use arr in state to store expandedrowKeys, directly
this.state.arr is like this: empty, not empty, empty, not empty.
make it in an unstable state, you should use stable array storage, and then periodically assign values to expandedrowskeys
this.state.expandedrowsKeys in state where there is always a value

.
Menu