Skip to content

Commit 5fdc7ef

Browse files
committed
Merge pull request #66 from eins78/master
remove internally used properties before server render
2 parents 62f9a71 + 25cd6f1 commit 5fdc7ef

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/react/rails/view_helper.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ def react_component(name, args = {}, options = {}, &block)
1515
data[:react_class] = name
1616
data[:react_props] = args.to_json unless args.empty?
1717
end
18-
html_tag = html_options.delete(:tag) || :div
19-
18+
html_tag = html_options[:tag] || :div
19+
20+
# remove internally used properties so they aren't rendered to DOM
21+
[:tag, :prerender].each{|prop| html_options.delete(prop)}
22+
2023
content_tag(html_tag, '', html_options, &block)
2124
end
2225

test/view_helper_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,10 @@ class ViewHelperTest < ActionDispatch::IntegrationTest
8787
assert_match /data-react-checksum/, page.html
8888
assert_match /yep/, page.find("#status").text
8989
end
90+
91+
test 'react server rendering does not include internal properties' do
92+
visit '/server/1'
93+
assert_no_match /tag=/, page.html
94+
assert_no_match /prerender=/, page.html
95+
end
9096
end

0 commit comments

Comments
 (0)