-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (29 loc) · 729 Bytes
/
Copy pathindex.js
File metadata and controls
34 lines (29 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
timer: null,
count: 0,
};
}
componentDidMount() {
const timer = setInterval(() => {
this.setState({
count: this.state.count + 1
});
}, 500);
this.setState({ timer });
}
componentWillUnmount() {
clearInterval(this.state.timer);
}
render() {
return (
<div>
<h1>React Fiddle <span>Remote</span></h1>
<span>Counter: {this.state.count}</span>
</div>
);
}
}
ReactDOM.render(<App/>, document.querySelector('.container'));