Sha256: 94199fb60135421173ff8ccc5c970db5d045f13ffc7d45bc92be717c6f257da6

Contents?: true

Size: 642 Bytes

Versions: 19

Compression:

Stored size: 642 Bytes

Contents

module React
  class Children
    include Enumerable

    def initialize(children)
      @children = children
    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

19 entries across 19 versions & 2 rubygems

Version Path
hyper-react-1.0.0.lap28 lib/react/children.rb
hyper-react-1.0.0.lap27 lib/react/children.rb
hyper-react-1.0.0.lap26 lib/react/children.rb
hyper-react-1.0.0.lap25 lib/react/children.rb
hyper-react-1.0.0.lap24 lib/react/children.rb
hyper-react-1.0.0.lap23 lib/react/children.rb
hyper-react-1.0.0.lap22 lib/react/children.rb
hyper-react-1.0.0.lap21 lib/react/children.rb
hyper-react-0.12.7 lib/react/children.rb
hyper-react-0.12.6 lib/react/children.rb
hyper-react-0.12.5 lib/react/children.rb
hyper-react-0.12.4 lib/react/children.rb
hyper-react-0.12.3 lib/react/children.rb
hyper-react-0.12.2 lib/react/children.rb
hyper-react-0.12.1 lib/react/children.rb
hyper-react-0.12.0 lib/react/children.rb
hyper-react-0.11.0 lib/react/children.rb
hyper-react-0.10.0 lib/react/children.rb
reactrb-0.9.0 lib/react/children.rb