Sha256: 9d33b22b65665f74be05d6a700e9857947c0e84ad18efdb8e29f0b9740a52065

Contents?: true

Size: 829 Bytes

Versions: 9

Compression:

Stored size: 829 Bytes

Contents

module React
  def self.render(element, container)
    container = `container.$$class ? container[0] : container`

    cb = %x{
      function(){
        setTimeout(function(){
          #{yield if block_given?}
        }, 0)
      }
    }

    if !(`typeof ReactDOM === 'undefined'`)
      native = `ReactDOM.render(#{element.to_n}, container, cb)` # v0.15+
    elsif !(`typeof React.renderToString === 'undefined'`)
      native = `React.render(#{element.to_n}, container, cb)`
    else
      raise "render is not defined.  In React >= v15 you must import it with ReactDOM"
    end

    if `#{native}._getOpalInstance !== undefined`
      `#{native}._getOpalInstance()`
    elsif `React.findDOMNode !== undefined && #{native}.nodeType === undefined`
      `React.findDOMNode(#{native})`
    else
      native
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hyper-react-0.12.7 lib/react/top_level_render.rb
hyper-react-0.12.6 lib/react/top_level_render.rb
hyper-react-0.12.5 lib/react/top_level_render.rb
hyper-react-0.12.4 lib/react/top_level_render.rb
hyper-react-0.12.3 lib/react/top_level_render.rb
hyper-react-0.12.2 lib/react/top_level_render.rb
hyper-react-0.12.1 lib/react/top_level_render.rb
hyper-react-0.12.0 lib/react/top_level_render.rb
hyper-react-0.11.0 lib/react/top_level_render.rb