Skip to content

Commit d8e85aa

Browse files
committed
patch native components #
1 parent 7e79a70 commit d8e85aa

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ruby/hyper-component/lib/hyperstack/internal/component/react_wrapper.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,18 @@ def self.import_native_component(opal_class, native_class)
2727
@@component_classes[opal_class] = native_class
2828
end
2929

30+
# patched
31+
# https://github.com/hyperstack-org/hyperstack/issues/305
3032
def self.eval_native_react_component(name)
3133
component = `eval(name)`
3234
raise "#{name} is not defined" if `#{component} === undefined`
33-
34-
component = `component.default` if `component.__esModule`
35+
component = `component.default` if `component.__esModule && component.default`
3536
is_component_class = `#{component}.prototype !== undefined` &&
36-
(`!!#{component}.prototype.isReactComponent` ||
37-
`!!#{component}.prototype.render`)
37+
(`!!#{component}.prototype.isReactComponent` ||
38+
`!!#{component}.prototype.render`)
39+
is_memo = `#{component}.type != undefined` && `typeof #{component}.type.render === "function"`
3840
has_render_method = `typeof #{component}.render === "function"`
39-
unless is_component_class || stateless?(component) || has_render_method
41+
unless is_component_class || stateless?(component) || has_render_method || is_memo
4042
raise 'does not appear to be a native react component'
4143
end
4244
component

0 commit comments

Comments
 (0)