Sha256: 4e683e89cf31514bbfe7ee738bd36c7d100bdb3d5156bf3f38be866cf9e1343f

Contents?: true

Size: 893 Bytes

Versions: 2

Compression:

Stored size: 893 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}.__opalInstance !== undefined && #{native_inst}.__opalInstance !== null`
              value.call(`#{native_inst}.__opalInstance`)
            elsif `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

2 entries across 2 versions & 1 rubygems

Version Path
hyper-react-1.0.0.lap22 lib/react/ref_callback.rb
hyper-react-1.0.0.lap21 lib/react/ref_callback.rb