Sha256: 0caa3231fa72c9a08974a21b05b101d31f42ccec991894e711b379b2192af43f

Contents?: true

Size: 821 Bytes

Versions: 10

Compression:

Stored size: 821 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
    
    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

10 entries across 10 versions & 2 rubygems

Version Path
hyper-component-0.99.1 lib/react/top_level_render.rb
hyper-component-0.99.0 lib/react/top_level_render.rb
hyper-react-1.0.0.lap28 lib/react/top_level_render.rb
hyper-react-1.0.0.lap27 lib/react/top_level_render.rb
hyper-react-1.0.0.lap26 lib/react/top_level_render.rb
hyper-react-1.0.0.lap25 lib/react/top_level_render.rb
hyper-react-1.0.0.lap24 lib/react/top_level_render.rb
hyper-react-1.0.0.lap23 lib/react/top_level_render.rb
hyper-react-1.0.0.lap22 lib/react/top_level_render.rb
hyper-react-1.0.0.lap21 lib/react/top_level_render.rb