Skip to content

Commit 0a9207b

Browse files
committed
Make TableRow's style stable
1 parent 3e5ad89 commit 0a9207b

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/TableRow.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ class TableRow extends React.Component {
5656
super(props);
5757

5858
this.shouldRender = props.visible;
59+
60+
// avoid creating new object which may fail the sCU.
61+
this.style = {};
5962
}
6063

6164
componentWillReceiveProps(nextProps) {
@@ -99,6 +102,20 @@ class TableRow extends React.Component {
99102
store.setState({ expandedRowsHeight });
100103
}
101104

105+
getStyle() {
106+
const { height, visible } = this.props;
107+
108+
if (height && height !== this.style.height) {
109+
this.style = { ...this.style, height };
110+
}
111+
112+
if (!visible && !this.style.display) {
113+
this.style = { ...this.style, display: 'none' };
114+
}
115+
116+
return this.style;
117+
}
118+
102119
saveRowRef = (node) => {
103120
this.rowRef = node;
104121
if (node) {
@@ -120,8 +137,6 @@ class TableRow extends React.Component {
120137
index,
121138
indent,
122139
indentSize,
123-
visible,
124-
height,
125140
hovered,
126141
hasExpandIcon,
127142
renderExpandIcon,
@@ -153,12 +168,6 @@ class TableRow extends React.Component {
153168
);
154169
}
155170

156-
const style = { height };
157-
158-
if (!visible) {
159-
style.display = 'none';
160-
}
161-
162171
const rowClassName =
163172
`${prefixCls} ${className} ${prefixCls}-level-${indent}`.trim();
164173

@@ -171,7 +180,7 @@ class TableRow extends React.Component {
171180
onMouseLeave={this.onMouseLeave}
172181
onContextMenu={this.onContextMenu}
173182
className={rowClassName}
174-
style={style}
183+
style={this.getStyle()}
175184
>
176185
{cells}
177186
</tr>

0 commit comments

Comments
 (0)