Method: React::Children#each

Defined in:
lib/react/children.rb

#each(&block) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/react/children.rb', line 17

def each(&block)
  return to_enum(__callee__) { length } unless block_given?
  return [] unless length > 0
  collection = []
  %x{
    React.Children.forEach(#{@children}, function(context){
      #{
        element = React::Element.new(`context`)
        block.call(element)
        collection << element
      }
    })
  }
  collection
end