class React::Component::Props

Public Class Methods

new(native) click to toggle source
# File lib/react/component/props.rb, line 4
def initialize(native)
  @native = native
end

Public Instance Methods

children() click to toggle source
# File lib/react/component/props.rb, line 23
def children
  @native.JS[:props].JS[:children]
end
classes() click to toggle source
# File lib/react/component/props.rb, line 19
def classes
  @classes ||= React::Component::Styles.new(@native, 'classes')
end
history() click to toggle source

for router convenience

# File lib/react/component/props.rb, line 36
def history
  return @history if @history
  return nil if `typeof #@native.props.history === 'undefined'`
  if `typeof #@native.props.history.action !== 'undefined'`
    @history = React::Component::History.new(@native)
  else
    @native.JS[:props].JS[:history]
  end
end
isomorfeus_store() click to toggle source
# File lib/react/component/props.rb, line 31
def isomorfeus_store
  @native.JS[:props].JS[:isomorfeus_store]
end
location() click to toggle source
# File lib/react/component/props.rb, line 46
def location
  return @location if @location
  return nil if `typeof #@native.props.location === 'undefined'`
  if `typeof #@native.props.location.pathname !== 'undefined'`
    @location = React::Component::Location.new(@native)
  else
    @native.JS[:props].JS[:location]
  end
end
match() click to toggle source
# File lib/react/component/props.rb, line 56
def match
  return @match if @match
  return nil if `typeof #@native.props.match === 'undefined'`
  if `typeof #@native.props.match.path !== 'undefined'`
    @match = React::Component::Match.new(@native)
  else
    @native.JS[:props].JS[:match]
  end
end
method_missing(prop, *args, &block) click to toggle source
# File lib/react/component/props.rb, line 8
def method_missing(prop, *args, &block)
  %x{
    const p = #@native.props;
    if (typeof p[prop] === 'undefined') {
      prop = Opal.React.lower_camelize(prop);
      if (typeof p[prop] === 'undefined') { return nil; }
    }
    return p[prop];
  }
end
theme() click to toggle source
# File lib/react/component/props.rb, line 27
def theme
  @theme ||= React::Component::Styles.new(@native, 'theme')
end
to_h() click to toggle source
# File lib/react/component/props.rb, line 66
def to_h
  `Opal.Hash.$new(#@native.props)`.transform_keys!(&:underscore)
end
to_json() click to toggle source
# File lib/react/component/props.rb, line 70
def to_json
  JSON.dump(to_transport)
end
to_n() click to toggle source
# File lib/react/component/props.rb, line 74
def to_n
  @native.JS[:props]
end
to_transport() click to toggle source
# File lib/react/component/props.rb, line 78
def to_transport
  {}.merge(to_h)
end