Skip to content

Commit 77910db

Browse files
committed
fix(table): update rowsMap after prop data update
affects: @crave/farmblocks-table
1 parent dff7515 commit 77910db

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/table/src/Table.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Table extends React.Component {
1717
expandedRows: []
1818
};
1919

20-
componentDidMount() {
20+
updateRowsMap() {
2121
const { rowGroupKey } = this.props;
2222
const hasSubRows = row =>
2323
rowGroupKey && row[rowGroupKey] && row[rowGroupKey].length;
@@ -40,6 +40,16 @@ class Table extends React.Component {
4040
this.setState({ rowsMap });
4141
}
4242

43+
componentDidMount() {
44+
this.updateRowsMap();
45+
}
46+
47+
componentDidUpdate(oldProps) {
48+
if (oldProps.data.length !== this.props.data.length) {
49+
this.updateRowsMap();
50+
}
51+
}
52+
4353
render() {
4454
const {
4555
data,

0 commit comments

Comments
 (0)