Module: React::Component::DslInstanceMethods
- Defined in:
- lib/react/component/dsl_instance_methods.rb
Instance Method Summary collapse
Instance Method Details
#children ⇒ Object
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 37 38 |
# File 'lib/react/component/dsl_instance_methods.rb', line 4 def children if `#{@native}.props.children==undefined` nodes = [] else nodes = [`#{@native}.props.children`].flatten end class << nodes include Enumerable def to_n self end def each(&block) if block_given? %x{ React.Children.forEach(#{self.to_n}, function(context){ #{yield React::Element.new(`context`)} }) } nil else Enumerator.new(`React.Children.count(#{self.to_n})`) do |y| %x{ React.Children.forEach(#{self.to_n}, function(context){ #{y << Element.new(`context`)} }) } end end end end nodes end |
#params ⇒ Object
40 41 42 |
# File 'lib/react/component/dsl_instance_methods.rb', line 40 def params @props_wrapper end |
#props ⇒ Object
44 45 46 |
# File 'lib/react/component/dsl_instance_methods.rb', line 44 def props Hash.new(`#{@native}.props`) end |
#refs ⇒ Object
48 49 50 |
# File 'lib/react/component/dsl_instance_methods.rb', line 48 def refs Hash.new(`#{@native}.refs`) end |
#state ⇒ Object
52 53 54 |
# File 'lib/react/component/dsl_instance_methods.rb', line 52 def state @state_wrapper ||= StateWrapper.new(@native, self) end |