Sha256: d2e9282d372c16787202aad99d8e0afae5c8b0a3a04991980ad5806f7e41cdfb
Contents?: true
Size: 833 Bytes
Versions: 3
Compression:
Stored size: 833 Bytes
Contents
module Hyperstack module Component 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 = Element.new(`context`, :wrap_child) block.call(element) collection << element } }) } collection end def length @length ||= `React.Children.count(#{@children})` end alias_method :size, :length end end end
Version data entries
3 entries across 3 versions & 1 rubygems