gregnb / gregnb/mui-datatables

Changing state with setState in onRowExpand collapses the expanded row

Open
#989 10 comments 0 reactions 1 assignee Claimed by @gabrielliwerant View on GitHub
bug v4 state/props
Dominant language
JavaScript
Stars
2.7k
Forks
906
PR merge metrics
No merged PRs in 30d

Description

All three versions try to showcase a general problem in the functionality of expandable rows. I was trying to make the program call for a get request from server and update the state of the data in the current expandable row. But although fetching the data correctly and storing it, and being displayed on screen for a second the setState itself was the cause that collapsed the expanded row.

As shown bellow three different ways that a setState is being called cause the same problem to occur.

[1]
`onTableChange: (action, tableState) => { switch (action) { case 'expandRow': this.setState({age: 1}) break; default: break; } }`

[2]
`onRowsExpand: (curExpanded, allExpanded) => { this.setState({age: 1}) }`

[3]
`onRowClick: (rowData, rowState) => { this.setState({age: 1}) }`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.