Skip to content

Commit 04dcb7d

Browse files
committed
Improve monitor shouldComponentUpdate
- did not tell apart 0 and -0 - would always re-render if value was NaN
1 parent 352845e commit 04dcb7d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎src/containers/monitor.jsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ class Monitor extends React.Component {
9191
for (const key of Object.getOwnPropertyNames(nextProps)) {
9292
// Don't need to rerender when other monitors are moved.
9393
// monitorLayout is only used during initial layout.
94-
if (key !== 'monitorLayout' && nextProps[key] !== this.props[key]) {
94+
// Using Object.is to tell apart 0 and -0 and avoid unnecessary re-renders for NaN
95+
if (key !== 'monitorLayout' && !Object.is(nextProps[key], this.props[key])) {
9596
return true;
9697
}
9798
}

0 commit comments

Comments
 (0)