Skip to content

Commit b95d6e5

Browse files
authored
Merge pull request #645 from reactjs/camelize-override-with-false
feat(ComponentMount) allow overriding camelize_props=true with local false
2 parents 41600e8 + dc58bea commit b95d6e5

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/react/rails/component_mount.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def teardown(env)
2424
# on the client.
2525
def react_component(name, props = {}, options = {}, &block)
2626
options = {:tag => options} if options.is_a?(Symbol)
27-
if camelize_props_switch || options[:camelize_props]
27+
if options.fetch(:camelize_props, camelize_props_switch)
2828
props = React.camelize_props(props)
2929
end
3030

test/react/rails/component_mount_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ class ComponentMountTest < ActionDispatch::IntegrationTest
3232
expected_props.each do |segment|
3333
assert html.include?(segment)
3434
end
35+
36+
React::Rails::ComponentMount.camelize_props_switch = true
37+
helper = React::Rails::ComponentMount.new
38+
html = helper.react_component('Foo', {foo_bar: 'value'}, camelize_props: false)
39+
expected_props = %w(data-react-class="Foo" data-react-props="{&quot;foo_bar&quot;:&quot;value&quot;}")
40+
expected_props.each do |segment|
41+
assert html.include?(segment)
42+
end
3543
end
3644

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

0 commit comments

Comments
 (0)