Skip to content

Commit 5811e32

Browse files
committed
Merge pull request mobxjs#1 from mohsen1/patch-1
Use `this` in AppState constructor for updating timer
2 parents 1256b8e + 328f584 commit 5811e32

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class AppState {
1111

1212
constructor() {
1313
setInterval(() => {
14-
appState.timer += 1;
14+
this.timer += 1;
1515
}, 1000);
1616
}
1717

@@ -39,4 +39,4 @@ class TimerView extends React.Component<{appState: AppState}, {}> {
3939
};
4040

4141
const appState = new AppState();
42-
ReactDOM.render(<TimerView appState={appState} />, document.getElementById('root'));
42+
ReactDOM.render(<TimerView appState={appState} />, document.getElementById('root'));

0 commit comments

Comments
 (0)