Merge pull request #1 from mohsen1/patch-1
Use `this` in AppState constructor for updating timer
This commit is contained in:
commit
5811e32f94
1 changed files with 2 additions and 2 deletions
|
|
@ -11,7 +11,7 @@ class AppState {
|
|||
|
||||
constructor() {
|
||||
setInterval(() => {
|
||||
appState.timer += 1;
|
||||
this.timer += 1;
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
|
|
@ -39,4 +39,4 @@ class TimerView extends React.Component<{appState: AppState}, {}> {
|
|||
};
|
||||
|
||||
const appState = new AppState();
|
||||
ReactDOM.render(<TimerView appState={appState} />, document.getElementById('root'));
|
||||
ReactDOM.render(<TimerView appState={appState} />, document.getElementById('root'));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue