Sha256: fda4d81db1fb41c2e313c3133d75dd66166cf4342d4d119ab9b239775e23a522

Contents?: true

Size: 831 Bytes

Versions: 8

Compression:

Stored size: 831 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}._getOpalInstance !== undefined`
              value.call(`#{native_inst}._getOpalInstance()`)
            elsif `React.findDOMNode !== undefined && #{native_inst}.nodeType === undefined`
              value.call(`React.findDOMNode(#{native_inst})`)
            else
              value.call(native_inst)
            end
          end
          props[key] = new_proc
        end
      end
      props
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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