Skip to content

Commit b26516f

Browse files
committed
docs(readMe): improve example
1 parent fcf67bc commit b26516f

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@ import React, { Component } from 'react'
1818
import easyState from 'react-easy-state'
1919

2020
@easyState
21-
export default class App extends Component {
22-
constructor () {
23-
super()
24-
this.state = { counter: 0 }
21+
class Counter extends Component {
22+
state = { value: 0 }
23+
24+
increment () {
25+
this.state++
2526
}
2627

27-
render () {
28-
const { counter } = this.state
28+
decrement () {
29+
this.state--
30+
}
2931

32+
render () {
3033
return (
3134
<div>
32-
<span>Counter: {counter}</span>
33-
<button onClick={this.increment}>Increment</button>
35+
{this.state.value}
36+
<button onClick={this.increment}>+</button>
37+
<button onClick={this.decrement}>-</button>
3438
</div>
3539
)
3640
}
37-
38-
increment () {
39-
this.state.counter++
40-
}
4141
}
4242
```
4343

0 commit comments

Comments
 (0)