Sha256: 2e20e780fa1e079f1e9da63340bbe572f299788eda69c10264b8721a097c53d2
Contents?: true
Size: 1.52 KB
Versions: 27
Compression:
Stored size: 1.52 KB
Contents
module React class ContextWrapper include ::Native::Wrapper def is_wrapped_context true end def Consumer(*args, &block) # why not use internal_prepare_args and render? %x{ let operabu = Opal.React.render_buffer; let props = null; if (args.length > 0) { props = Opal.React.to_native_react_props(args[0]); } let react_element = Opal.global.React.createElement(this.native.Consumer, props, function(value) { let children = null; if (block !== nil) { operabu.push([]); // console.log("consumer pushed", operabu, operabu.toString()); let block_result = block.$call(); if (block_result && (block_result.constructor === String || block_result.constructor === Number)) { operabu[operabu.length - 1].push(block_result); } // console.log("consumer popping", operabu, operabu.toString()); children = operabu.pop(); if (children.length == 1) { children = children[0]; } else if (children.length == 0) { children = null; } } return children; }); operabu[operabu.length - 1].push(react_element); } end def Provider(*args, &block) # why not use internal_prepare_args and render? %x{ var props = null; if (args.length > 0) { props = Opal.React.to_native_react_props(args[0]); } Opal.React.internal_render(this.native.Provider, props, null, block); } end end end
Version data entries
27 entries across 27 versions & 1 rubygems