Sha256: 83f6edb78297e030fa6a151709f80c163ae35d92ec7f4e421ee54bc3e4bd21d5

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module LucidPaper
  module Component
    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 = Opal.global.React.memo(function(props) {
            let classes = null;
            let store;
            if (base.store_updates) { store = Opal.global.React.useContext(Opal.global.LucidApplicationContext); }
            let new_props = Object.assign({}, props)
            new_props.store = store;
            new_props.theme = Opal.global.Paper.useTheme();
            return Opal.global.React.createElement(base.lucid_react_component, new_props);
          }, Opal.React.props_are_equal);
          base.react_component.displayName = #{component_name};
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
isomorfeus-react-16.13.12 lib/isomorfeus_react_paper/lucid_paper/component/native_component_constructor.rb