Skip to content

Commit d6c2254

Browse files
committed
Update example in README
1 parent 786687f commit d6c2254

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

‎README.md‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
[GopherJS](https://github.com/gopherjs/gopherjs) bindings for Facebook React.
99

10-
**NOTE: Still very early and not production ready.**
10+
**NOTE: Still early and not production ready.**
1111

1212
## Examples
1313

@@ -33,16 +33,18 @@ func main() {
3333
})
3434
}
3535

36-
type clickCounter int
36+
type clickCounter struct {
37+
*gr.This
38+
}
3739

3840
// Implements the StateInitializer interface.
39-
func (c clickCounter) GetInitialState(this *gr.This) gr.State {
41+
func (c clickCounter) GetInitialState() gr.State {
4042
return gr.State{"counter": 0}
4143
}
4244

4345
// Implements the Renderer interface.
44-
func (c clickCounter) Render(this *gr.This) gr.Component {
45-
counter := this.State()["counter"]
46+
func (c clickCounter) Render() gr.Component {
47+
counter := c.State()["counter"]
4648
message := fmt.Sprintf(" Click me! Number of clicks: %v", counter)
4749

4850
elem := el.Div(
@@ -55,13 +57,13 @@ func (c clickCounter) Render(this *gr.This) gr.Component {
5557
return examples.Example("Click Counter", elem)
5658
}
5759

58-
func (c clickCounter) onClick(this *gr.This, event *gr.Event) {
59-
this.SetState(gr.State{"counter": this.State().Int("counter") + 1})
60+
func (c clickCounter) onClick(event *gr.Event) {
61+
c.SetState(gr.State{"counter": c.State().Int("counter") + 1})
6062
}
6163

6264
// Implements the ShouldComponentUpdate interface.
63-
func (c clickCounter) ShouldComponentUpdate(this *gr.This, next gr.Cops) bool {
64-
return this.State().HasChanged(next.State, "counter")
65+
func (c clickCounter) ShouldComponentUpdate(next gr.Cops) bool {
66+
return c.State().HasChanged(next.State, "counter")
6567
}
6668
```
6769

0 commit comments

Comments
 (0)