Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/react/rails/view_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ def react_component(name, args = {}, options = {}, &block)
data[:react_class] = name
data[:react_props] = args.to_json unless args.empty?
end
html_tag = html_options.delete(:tag) || :div

html_tag = html_options[:tag] || :div

# remove internally used properties so they aren't rendered to DOM
[:tag, :prerender].each{|prop| html_options.delete(prop)}

content_tag(html_tag, '', html_options, &block)
end

Expand Down
6 changes: 6 additions & 0 deletions test/view_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,10 @@ class ViewHelperTest < ActionDispatch::IntegrationTest
assert_match /data-react-checksum/, page.html
assert_match /yep/, page.find("#status").text
end

test 'react server rendering does not include internal properties' do
visit '/server/1'
assert_no_match /tag=/, page.html
assert_no_match /prerender=/, page.html
end
end