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

Commit 9a40e91

Browse files
committed
html rendered should update as instance changes
1 parent 00ce6e7 commit 9a40e91

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/react/test/session.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ def force_update!
3131
end
3232

3333
def html
34-
React.render_to_static_markup(element)
34+
# How can we get the current ReactElement w/o violating private APIs?
35+
elem = Native(native[:_reactInternalInstance][:_currentElement])
36+
React.render_to_static_markup(elem)
3537
end
3638
end
3739
end

spec/react/test/session_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ def render
6161
subject.mount(Greeter, message: 'world')
6262
expect(subject.html).to eq('<span>Hello world</span>')
6363
end
64+
65+
it 'returns the updated static html' do
66+
subject.mount(Greeter)
67+
subject.update_params(message: 'moon')
68+
expect(subject.html).to eq('<span>Hello moon</span>')
69+
end
6470
end
6571

6672
describe '#update_params' do

0 commit comments

Comments
 (0)