Skip to content

Commit c336f94

Browse files
- remove legacy function usage from examples
1 parent 650a228 commit c336f94

File tree

6 files changed

+8
-15
lines changed

6 files changed

+8
-15
lines changed

examples/event_handling/events_handling_def.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func init() {
4848
return func(this *js.Object, e *react.SyntheticEvent, props, state react.Map, setState react.SetState) {
4949

5050
var eState eventsState
51-
react.HydrateState(this, &eState)
51+
react.UnmarshalState(this, &eState)
5252

5353
// Update counter
5454
setState(func(props, state react.Map) interface{} {

examples/event_handling/main.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ package main
33
import (
44
"github.com/gopherjs/gopherjs/js"
55
"github.com/rocketlaunchr/react"
6-
"honnef.co/go/js/dom"
76
)
87

9-
var document = dom.GetWindow().Document()
10-
118
func main() {
12-
domTarget := document.GetElementByID("app")
9+
domTarget := react.GetElementByID("app")
1310

1411
// An example using Functional Components
1512
// See: https://reactjs.org/docs/components-and-props.html

examples/event_handling/title_def.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func init() {
2121
titleDef.Render(func(this *js.Object, props, state react.Map) interface{} {
2222

2323
var tProps TitleProps
24-
react.HydrateProps(this, &tProps)
24+
react.UnmarshalProps(this, &tProps)
2525

2626
title := tProps.Title
2727

examples/uptime/main.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@ package main
22

33
import (
44
"github.com/rocketlaunchr/react"
5-
"honnef.co/go/js/dom"
65
)
76

8-
var document = dom.GetWindow().Document()
9-
107
func main() {
11-
domTarget := document.GetElementByID("app")
8+
domTarget := react.GetElementByID("app")
129

1310
title := "UPTIME TIMER"
1411

1512
react.Render(react.JSX(ContainerComponent, &ContainerProps{Title: title}), domTarget)
16-
1713
}

examples/uptime/timer_def.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func init() {
3232

3333
// Using props in here is considered bad practice. It is only for example purposes.
3434
var tProps TimerProps
35-
react.HydrateProps(this, &tProps)
35+
react.UnmarshalProps(this, &tProps)
3636

3737
return TimerState{
3838
Elapsed: time.Now().Unix() - tProps.StartTime,
@@ -47,7 +47,7 @@ func init() {
4747
timerDef.SetMethod("tick", func(this *js.Object, props, state react.Map, setState react.SetState, arguments []*js.Object) interface{} {
4848

4949
var tProps TimerProps
50-
react.HydrateProps(this, &tProps)
50+
react.UnmarshalProps(this, &tProps)
5151

5252
elapsed := time.Now().Unix() - tProps.StartTime
5353

@@ -67,7 +67,7 @@ func init() {
6767
timerDef.Render(func(this *js.Object, props, state react.Map) interface{} {
6868

6969
var tState TimerState
70-
react.HydrateState(this, &tState)
70+
react.UnmarshalState(this, &tState)
7171

7272
text := "Uptime counter:" + strconv.Itoa(int(tState.Elapsed))
7373

examples/uptime/title_def.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func init() {
2121
titleDef.Render(func(this *js.Object, props, state react.Map) interface{} {
2222

2323
var tProps TitleProps
24-
react.HydrateProps(this, &tProps)
24+
react.UnmarshalProps(this, &tProps)
2525

2626
title := tProps.Title
2727

0 commit comments

Comments
 (0)