Sha256: 75f3bfdae1caf0d831b8f7f64b05d050ca75f7ca6d07dd08d9ded4530877ec1b

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

module LucidPaper
  module App
    module NativeComponentConstructor
      # for should_component_update we apply ruby semantics for comparing props
      # to do so, we convert the props to ruby hashes and then compare
      # this makes sure, that for example rubys Nil object gets handled properly
      def self.extended(base)
        %x{
          base.jss_theme = Opal.global.Paper.DefaultTheme;
          base.themed_component = Opal.global.Paper.withTheme(base.lucid_react_component);
          base.react_component = class extends Opal.global.React.Component {
            constructor(props) {
              super(props);
              if (Opal.Isomorfeus.$top_component() == nil) { Opal.Isomorfeus['$top_component='](this); }
            }
            static get displayName() {
              return "IsomorfeusTopLevelComponent";
            }
            static set displayName(new_name) {
              // dont do anything here except returning the set value
              return new_name;
            }
            render() {
              let themed_component = Opal.global.React.createElement(base.themed_component, this.props);
              return Opal.global.React.createElement(Opal.global.Paper.Provider, { theme: base.jss_theme }, themed_component);
            }
          }
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
isomorfeus-react-16.13.11 lib/isomorfeus_react_paper/lucid_paper/app/native_component_constructor.rb