Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Commit d136e15

Browse files
committed
[React::Test::Session] Fix for reactjs-v15
`set_props` is no longer working in v15, we simply render again instead.
1 parent 52981e2 commit d136e15

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/react/test/session.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,26 @@ def mount(component_klass, params = {})
1010
end
1111

1212
def instance
13-
@instance ||= `#{native.to_n}._getOpalInstance.apply(#{native})`
13+
unless @instance
14+
@native = Native(`React.addons.TestUtils.renderIntoDocument(#{element.to_n})`)
15+
@instance = `#{@native.to_n}._getOpalInstance()`
16+
end
17+
@instance
1418
end
1519

1620
def native
17-
@native ||= Native(
18-
`React.addons.TestUtils.renderIntoDocument(#{element.to_n})`)
21+
@native
1922
end
2023

2124
def element
2225
@element
2326
end
2427

2528
def update_params(params)
26-
native.set_props(params)
29+
cloned_element = React::Element.new(`React.cloneElement(#{self.element.to_n}, #{params.to_n})`)
30+
prev_container = `#{self.instance.dom_node}.parentNode`
31+
React.render(cloned_element, prev_container)
32+
nil
2733
end
2834

2935
def force_update!
@@ -38,4 +44,3 @@ def html
3844
end
3945
end
4046
end
41-

0 commit comments

Comments
 (0)