Sha256: 02c53d0107cc30a8240e2e8dd1f57baf096818c658cdb2e3c7e71781cc90812a
Contents?: true
Size: 1.06 KB
Versions: 34
Compression:
Stored size: 1.06 KB
Contents
module React module MemoComponent module Creator def self.extended(base) %x{ base.equality_checker = null; base.react_component = Opal.global.React.memo(function(props) { Opal.React.render_buffer.push([]); Opal.React.active_components.push(base); #{base.new(`props`).instance_exec(&`base.function_block`)}; Opal.React.active_components.pop(); return Opal.React.render_buffer.pop(); }, base.equality_checker); } def props_are_equal?(&block) %x{ base.equality_checker = function (prev_props, next_props) { var prev_ruby_props = Opal.React.Component.Props.$new({props: prev_props}); var next_ruby_props = Opal.React.Component.Props.$new({props: next_props}); return #{base.new(`{}`).instance_exec(`prev_ruby_props`, `next_ruby_props`, &block)}; } } end def create_memo(&block) `base.function_block = #{block}` end end end end end
Version data entries
34 entries across 34 versions & 1 rubygems