Sha256: d686ca50de1af4ce764618cb380481bcc467af7ce38b5c799f7bd6accb1556f9
Contents?: true
Size: 1.42 KB
Versions: 9
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 classes = null; let store; if (base.store_updates) { store = Opal.global.React.useContext(Opal.global.LucidApplicationContext); } let theme = Opal.global.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 = Opal.global.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 Opal.global.React.createElement(base.lucid_react_component, new_props); } base.react_component.displayName = #{component_name}; } end end end
Version data entries
9 entries across 9 versions & 1 rubygems