Sha256: bf451be749d9091dcf7a1fbb458575316cc6129c43f9051e588949c221e1828f

Contents?: true

Size: 857 Bytes

Versions: 5

Compression:

Stored size: 857 Bytes

Contents

module React
  def self.render(element, container)
    raise "ReactDOM.render is not defined.  In React >= v15 you must import it with ReactDOM" if (`typeof ReactDOM === 'undefined'`)

    container = `container.$$class ? container[0] : container`

    if block_given?
      cb = %x{
        function(){
          setTimeout(function(){
            #{yield}
          }, 0)
        }
      }
      native = `ReactDOM.render(#{element.to_n}, container, cb)`
    else
      native = `ReactDOM.render(#{element.to_n}, container)`
    end

    return unless `#{native} !== null`

    if `#{native}.__opalInstance !== undefined && #{native}.__opalInstance !== null`
      `#{native}.__opalInstance`
    elsif `ReactDOM.findDOMNode !== undefined && #{native}.nodeType === undefined`
      `ReactDOM.findDOMNode(#{native})`
    else
      native
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hyper-component-0.99.6 lib/react/top_level_render.rb
hyper-component-0.99.5 lib/react/top_level_render.rb
hyper-component-0.99.4 lib/react/top_level_render.rb
hyper-component-0.99.3 lib/react/top_level_render.rb
hyper-component-0.99.2 lib/react/top_level_render.rb