Skip to content

Commit

Permalink
- remove legacy function usage from examples
Browse files Browse the repository at this point in the history
  • Loading branch information
rocketlaunchr-cto committed Jul 26, 2019
1 parent 650a228 commit c336f94
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/event_handling/events_handling_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func init() {
return func(this *js.Object, e *react.SyntheticEvent, props, state react.Map, setState react.SetState) {

var eState eventsState
react.HydrateState(this, &eState)
react.UnmarshalState(this, &eState)

// Update counter
setState(func(props, state react.Map) interface{} {
Expand Down
5 changes: 1 addition & 4 deletions examples/event_handling/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ package main
import (
"github.com/gopherjs/gopherjs/js"
"github.com/rocketlaunchr/react"
"honnef.co/go/js/dom"
)

var document = dom.GetWindow().Document()

func main() {
domTarget := document.GetElementByID("app")
domTarget := react.GetElementByID("app")

// An example using Functional Components
// See: https://reactjs.org/docs/components-and-props.html
Expand Down
2 changes: 1 addition & 1 deletion examples/event_handling/title_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func init() {
titleDef.Render(func(this *js.Object, props, state react.Map) interface{} {

var tProps TitleProps
react.HydrateProps(this, &tProps)
react.UnmarshalProps(this, &tProps)

title := tProps.Title

Expand Down
6 changes: 1 addition & 5 deletions examples/uptime/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ package main

import (
"github.com/rocketlaunchr/react"
"honnef.co/go/js/dom"
)

var document = dom.GetWindow().Document()

func main() {
domTarget := document.GetElementByID("app")
domTarget := react.GetElementByID("app")

title := "UPTIME TIMER"

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

}
6 changes: 3 additions & 3 deletions examples/uptime/timer_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func init() {

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

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

var tProps TimerProps
react.HydrateProps(this, &tProps)
react.UnmarshalProps(this, &tProps)

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

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

var tState TimerState
react.HydrateState(this, &tState)
react.UnmarshalState(this, &tState)

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

Expand Down
2 changes: 1 addition & 1 deletion examples/uptime/title_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func init() {
titleDef.Render(func(this *js.Object, props, state react.Map) interface{} {

var tProps TitleProps
react.HydrateProps(this, &tProps)
react.UnmarshalProps(this, &tProps)

title := tProps.Title

Expand Down

0 comments on commit c336f94

Please sign in to comment.