-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathreact.go
36 lines (29 loc) · 1023 Bytes
/
react.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2018 PJ Engineering and Business Solutions Pty. Ltd. All rights reserved.
package react
import (
"github.com/gopherjs/gopherjs/js"
"honnef.co/go/js/dom"
)
var (
// React points to the React library. Change it
// if it is not in your global namespace.
//
// See: https://www.npmjs.com/package/react
React = js.Global.Get("React")
// ReactDOM points to the ReactDOM library. Change it
// if it is not in your global namespace.
//
// See: https://www.npmjs.com/package/react-dom
ReactDOM = js.Global.Get("ReactDOM")
// CreateReactClass points to create-react-class module.
//
// See: https://www.npmjs.com/package/create-react-class
CreateReactClass = js.Global
)
// Render will render component to the specified target dom element.
func Render(element *js.Object, domTarget dom.Element, callback ...func()) *js.Object {
if len(callback) > 0 && callback[0] != nil {
return ReactDOM.Call("render", element, domTarget, callback[0])
}
return ReactDOM.Call("render", element, domTarget)
}