Sha256: 6ffa027ce7f59951cd499160abaa6edaff1035dc8140b4304588dc49d1e44bd7

Contents?: true

Size: 948 Bytes

Versions: 13

Compression:

Stored size: 948 Bytes

Contents

require 'react/native_library'

module React
  module RefsCallbackExtension
  end

  class API
    class << self
      alias :orig_convert_props :convert_props
    end

    def self.convert_props(properties)
      props = self.orig_convert_props(properties)
      props.map do |key, value|
        if key == "ref" && value.is_a?(Proc)
          new_proc = Proc.new do |native_inst|
            if `#{native_inst} !== null && #{native_inst}.__opalInstance !== undefined && #{native_inst}.__opalInstance !== null`
              value.call(`#{native_inst}.__opalInstance`)
            elsif `#{native_inst} !== null &&  ReactDOM.findDOMNode !== undefined && #{native_inst}.nodeType === undefined`
              value.call(`ReactDOM.findDOMNode(#{native_inst})`) # react >= v0.15.`)
            else
              value.call(native_inst)
            end
          end
          props[key] = new_proc
        end
      end
      props
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
hyper-component-0.99.6 lib/react/ref_callback.rb
hyper-component-0.99.5 lib/react/ref_callback.rb
hyper-component-0.99.4 lib/react/ref_callback.rb
hyper-component-0.99.3 lib/react/ref_callback.rb
hyper-component-0.99.2 lib/react/ref_callback.rb
hyper-component-0.99.1 lib/react/ref_callback.rb
hyper-component-0.99.0 lib/react/ref_callback.rb
hyper-react-1.0.0.lap28 lib/react/ref_callback.rb
hyper-react-1.0.0.lap27 lib/react/ref_callback.rb
hyper-react-1.0.0.lap26 lib/react/ref_callback.rb
hyper-react-1.0.0.lap25 lib/react/ref_callback.rb
hyper-react-1.0.0.lap24 lib/react/ref_callback.rb
hyper-react-1.0.0.lap23 lib/react/ref_callback.rb