Sha256: 9b4463a4f49ec3c791573c9f8324891975634af9352a0eedb3d24d0809db3a39

Contents?: true

Size: 1.69 KB

Versions: 9

Compression:

Stored size: 1.69 KB

Contents

module React
  module Component
    class Props
      include ::Native::Wrapper

      def method_missing(prop, *args, &block)
        %x{
          var prop_name = Opal.React.lower_camelize(prop);
          if (typeof #@native.props[prop_name] === 'undefined') { return #{nil}; }
          return #@native.props[prop_name];
        }
      end

      def classes
        @classes ||= `Opal.React.Component.Styles.$new(#@native.props.classes)`
      end

      def theme
        @theme ||= `Opal.React.Component.Styles.$new(#@native.props.theme)`
      end

      def isomorfeus_store
        @native.JS[:props].JS[:isomorfeus_store]
      end

      # for router convenience
      def history
        return @history if @history
        return nil unless @native.JS[:props].JS[:history]
        if @native.JS[:props].JS[:history].JS[:pathname]
          @history = React::Component::History.new(@native.JS[:props].JS[:history])
        else
          @native.JS[:props].JS[:history]
        end
      end

      def location
        return @location if @location
        return nil unless @native.JS[:props].JS[:location]
        if @native.JS[:props].JS[:location].JS[:pathname]
          @location = React::Component::Location.new(@native.JS[:props].JS[:location])
        else
          @native.JS[:props].JS[:location]
        end
      end

      def match
        return @match if @match
        return nil unless @native.JS[:props].JS[:match]
        if @native.JS[:props].JS[:match].JS[:path]
          @match = React::Component::Match.new(@native.JS[:props].JS[:match])
        else
          @native.JS[:props].JS[:match]
        end
      end

      def to_n
        @native.JS[:props]
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
isomorfeus-react-16.9.23 lib/react/component/props.rb
isomorfeus-react-16.9.22 lib/react/component/props.rb
isomorfeus-react-16.9.21 lib/react/component/props.rb
isomorfeus-react-16.9.20 lib/react/component/props.rb
isomorfeus-react-16.9.19 lib/react/component/props.rb
isomorfeus-react-16.9.18 lib/react/component/props.rb
isomorfeus-react-16.9.17 lib/react/component/props.rb
isomorfeus-react-16.9.16 lib/react/component/props.rb
isomorfeus-react-16.9.15 lib/react/component/props.rb