Sha256: 425e8687fdf472a8838885d489556c9e0a91fcddc4b67a631c43cfc3373fa3a9

Contents?: true

Size: 1.42 KB

Versions: 27

Compression:

Stored size: 1.42 KB

Contents

module LucidComponent
  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)
      component_name = base.to_s + 'Wrapper'
      # language=JS
      %x{
        base.react_component = function(props) {
          let opag = Opal.global;
          let classes = null;
          let store;
          if (base.store_updates) { store = opag.React.useContext(opag.LucidApplicationContext); }
          let theme = opag.ReactJSS.useTheme();
          if (base.jss_styles) {
            if (!base.use_styles || (Opal.Isomorfeus.development && Opal.Isomorfeus.development !== nil)) {
              let styles;
              if (typeof base.jss_styles === 'function') { styles = base.jss_styles(theme); }
              else { styles = base.jss_styles; }
              base.use_styles = opag.ReactJSS.createUseStyles(styles);
            }
            classes = base.use_styles();
          }
          let new_props = Object.assign({}, props)
          new_props.classes = classes;
          new_props.theme = theme;
          new_props.store = store;
          return opag.React.createElement(base.lucid_react_component, new_props);
        }
        base.react_component.displayName = #{component_name};
      }
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
isomorfeus-react-16.13.6 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.13.5 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.13.4 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.13.3 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.13.2 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.13.1 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.13.0 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.12.24 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.12.23 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.12.22 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.12.21 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.12.20 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.12.19 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.12.18 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.12.17 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.12.16 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.12.15 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.12.14 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.12.13 lib/isomorfeus_react/lucid_component/native_component_constructor.rb
isomorfeus-react-16.12.12 lib/isomorfeus_react/lucid_component/native_component_constructor.rb