Skip to content

Commit 4de557f

Browse files
committed
fix perf improvements
1 parent 0b8a819 commit 4de557f

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

tea-cup/src/TeaCup/Memo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ class Memo<T> extends React.Component<MemoProps> {
5959
}
6060

6161
shouldComponentUpdate(nextProps: Readonly<MemoProps>, nextState: Readonly<{}>, nextContext: any): boolean {
62-
return this.props.compareFn(this.props.value, nextProps.value);
62+
return !this.props.compareFn(this.props.value, nextProps.value);
6363
}
6464
}

tea-cup/src/TeaCup/Program.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,24 @@ export class Program<Model, Msg> extends Component<ProgramProps<Model, Msg>, nev
9494
// perform commands in a separate timout, to
9595
// make sure that this dispatch is done
9696
const cmd = updated[1];
97-
// if (!(cmd instanceof CmdNone)) {
97+
if (!(cmd instanceof CmdNone)) {
9898
setTimeout(() => {
9999
// console.log("dispatch: processing commands");
100100
// debug("performing command", updated[1]);
101101
updated[1].execute(d);
102102
// debug("<<< done");
103103
}, 0);
104-
// }
104+
}
105105

106-
// const needsUpdate = this.currentModel === updated[0];
106+
const needsUpdate = this.currentModel !== updated[0];
107107

108108
this.currentModel = updated[0];
109109
this.currentSub = newSub;
110110

111111
// trigger rendering
112-
// console.log('render')
113-
// if (needsUpdate) {
114-
// console.log('render update')
112+
if (needsUpdate) {
115113
this.forceUpdate();
116-
// }
114+
}
117115
}
118116
}
119117

0 commit comments

Comments
 (0)