lib/react/component/api.rb in isomorfeus-react-16.12.5 vs lib/react/component/api.rb in isomorfeus-react-16.12.6
- old
+ new
@@ -65,9 +65,19 @@
else
@native.JS.forceUpdate
end
end
+ def component_fun(class_name, **ruby_props)
+ %x{
+ return function(props) {
+ let outer_props = Opal.React.to_native_react_props(#{ruby_props});
+ let new_props = Object.assign({}, props, outer_props);
+ return Opal.global.React.createElement(#{class_name.constantize}.react_component, new_props)
+ }
+ }
+ end
+
def get_react_element(arg, &block)
if block_given?
# execute block, fetch last element from buffer
%x{
let last_buffer_length = Opal.React.render_buffer[Opal.React.render_buffer.length - 1].length;