github.com/jgarto/itcv@v0.0.0-20180826224514-4eea09c1aa0d/examples/hellomessage/hello_message.go (about) 1 package hellomessage // import "myitcv.io/react/examples/hellomessage" 2 3 import ( 4 "myitcv.io/react" 5 ) 6 7 //go:generate reactGen 8 9 // HelloMessageDef is the definition of the HelloMessage component 10 type HelloMessageDef struct { 11 react.ComponentDef 12 } 13 14 // HelloMessageProps is the props type for the HelloMessage component 15 type HelloMessageProps struct { 16 Name string 17 } 18 19 // HelloMessage creates instances of the HelloMessage component 20 func HelloMessage(p HelloMessageProps, children ...react.Element) *HelloMessageElem { 21 return buildHelloMessageElem(p, children...) 22 } 23 24 // Render renders the HelloMessage component 25 func (h HelloMessageDef) Render() *react.DivElem { 26 kids := []react.Element{react.S("Hello " + h.Props().Name)} 27 28 for _, v := range h.Children() { 29 kids = append(kids, v) 30 } 31 32 return react.Div(nil, 33 kids..., 34 ) 35 } 36 37 func (h HelloMessageDef) RendersDiv(*react.DivElem) {}