Improve monitor shouldComponentUpdate
- did not tell apart 0 and -0 - would always re-render if value was NaN
This commit is contained in:
1 parent
352845e5d7
commit
04dcb7dcf4
1 file changed
+2
-1
@@ -91,7 +91,8 @@ class Monitor extends React.Component {
|
||||
for (const key of Object.getOwnPropertyNames(nextProps)) {
|
||||
// Don't need to rerender when other monitors are moved.
|
||||
// monitorLayout is only used during initial layout.
|
||||
if (key !== 'monitorLayout' && nextProps[key] !== this.props[key]) {
|
||||
// Using Object.is to tell apart 0 and -0 and avoid unnecessary re-renders for NaN
|
||||
if (key !== 'monitorLayout' && !Object.is(nextProps[key], this.props[key])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user