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
2 changes: 1 addition & 1 deletion lib/react/rails/component_mount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def teardown(env)
# on the client.
def react_component(name, props = {}, options = {}, &block)
options = {:tag => options} if options.is_a?(Symbol)
if camelize_props_switch || options[:camelize_props]
if options.fetch(:camelize_props, camelize_props_switch)
props = React.camelize_props(props)
end

Expand Down
8 changes: 8 additions & 0 deletions test/react/rails/component_mount_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ class ComponentMountTest < ActionDispatch::IntegrationTest
expected_props.each do |segment|
assert html.include?(segment)
end

React::Rails::ComponentMount.camelize_props_switch = true
helper = React::Rails::ComponentMount.new
html = helper.react_component('Foo', {foo_bar: 'value'}, camelize_props: false)
expected_props = %w(data-react-class="Foo" data-react-props="{&quot;foo_bar&quot;:&quot;value&quot;}")
expected_props.each do |segment|
assert html.include?(segment)
end
end

test '#react_component accepts React props with camelize_props containing nested arrays' do
Expand Down