Skip to content

Commit efb2db4

Browse files
committed
refactor(display): shouldComponentUpdate, let's find out
1 parent 6436942 commit efb2db4

File tree

1 file changed

+14
-1
lines changed
  • src/notebook/components/cell/display-area

1 file changed

+14
-1
lines changed

src/notebook/components/cell/display-area/display.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,20 @@ export default class Display extends React.Component {
2727
};
2828

2929
shouldComponentUpdate(nextProps: Props): boolean {
30-
return true;
30+
if (!nextProps || !this.props) {
31+
return false;
32+
}
33+
34+
const themeChanged = nextProps.theme && nextProps.theme !== this.props.theme;
35+
if (themeChanged) {
36+
return true;
37+
}
38+
39+
if (nextProps.outputs && !nextProps.outputs.equals(this.props.outputs)) {
40+
return true;
41+
}
42+
43+
return false;
3144
}
3245

3346
render() {

0 commit comments

Comments
 (0)