File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,30 @@ func (p Props) Interface(key string) interface{} {
167167 return nil
168168}
169169
170+ // Int is convenience method to lookup a int value from props.
171+ func (p Props ) Int (key string ) int {
172+ if val , ok := p [key ]; ok {
173+ return val .(* js.Object ).Int ()
174+ }
175+ return 0
176+ }
177+
178+ // Bool is convenience method to lookup a bool value from props.
179+ func (p Props ) Bool (key string ) bool {
180+ if val , ok := p [key ]; ok {
181+ return val .(* js.Object ).Bool ()
182+ }
183+ panic (fmt .Sprintf ("Props variable %q not found" , key ))
184+ }
185+
186+ // String is convenience method to lookup a bool value from props.
187+ func (p Props ) String (key string ) string {
188+ if val , ok := p [key ]; ok {
189+ return val .(* js.Object ).String ()
190+ }
191+ return ""
192+ }
193+
170194// Children represents a component's child component(s).
171195// This is a fairly complex topic in Facebook's React, and more support may arrive here, eventually.
172196// See https://facebook.github.io/react/tips/children-props-type.html
You can’t perform that action at this time.
0 commit comments