Sha256: d87b5a2c0616a46619a1d944fa6fe60fba39f4478818c056cf5ea2b26008aa7b
Contents?: true
Size: 735 Bytes
Versions: 7
Compression:
Stored size: 735 Bytes
Contents
module React class Children include Enumerable def initialize(children) @children = children end def render each(&:render) end def to_proc -> () { render } end 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 def length @length ||= `React.Children.count(#{@children})` end alias_method :size, :length end end
Version data entries
7 entries across 7 versions & 1 rubygems