mirror of
https://github.com/gregberge/loadable-components.git
synced 2026-01-18 15:12:26 +00:00
24 lines
396 B
JavaScript
24 lines
396 B
JavaScript
import React from 'react'
|
|
|
|
class Counter extends React.Component {
|
|
state = { count: 0 }
|
|
|
|
componentDidMount() {
|
|
this.interval = setInterval(
|
|
() =>
|
|
this.setState(previousState => ({ count: previousState.count + 1 })),
|
|
500,
|
|
)
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
clearInterval(this.interval)
|
|
}
|
|
|
|
render() {
|
|
return this.state.count
|
|
}
|
|
}
|
|
|
|
export default Counter
|