Skip to content

Commit 0af13e1

Browse files
committed
feat (easyComp): add support for stateless components
1 parent f209b6a commit 0af13e1

33 files changed

+76677
-74348
lines changed

examples/clock/App.jsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React, { Component } from 'react'
2+
import ReactDOM from 'react-dom'
3+
import moment from 'moment'
4+
import { easyComp } from 'react-easy-state'
5+
6+
class App extends Component {
7+
constructor () {
8+
super()
9+
10+
this.state = {
11+
clock: setInterval(() => this.setTime(), 1000)
12+
}
13+
this.setTime()
14+
}
15+
16+
setTime () {
17+
this.state.time = moment().format('hh:mm:ss A')
18+
}
19+
20+
componentWillUnmount () {
21+
clearInterval(this.state.clock)
22+
}
23+
24+
render() {
25+
return <div>{this.state.time}</div>
26+
}
27+
}
28+
29+
const app = React.createElement(easyComp(App))
30+
ReactDOM.render(app, document.getElementById('react-root'))
File renamed without changes.

0 commit comments

Comments
 (0)