Skip to content

Conversation

@ZhangHanDong
Copy link
Contributor

Camle-Case in es6.jsx:

static propTypes = {
        form: PropTypes.object,
        errorMessages: PropTypes.array,
        defaultFieldValues: PropTypes.object
    }

I must be camle-case in Rails:

props = {form: {action: "new"}, errorMessages: ["errors1, errors2"], defaultFieldValues:  {some: "value"}}

I think it's better in Rails:

props = {form: {action: "new"}, error_messages: ["errors1, errors2"], default_field_values: {some: "value"}}

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@rmosolgo
Copy link
Member

Hi! Thanks for adding this feature. I can see how useful this will be!

How about making this an opt-in feature? I can think of two ways to make this opt-in:

  • Add a config, like config.camelize_props = true
  • Make the view helper public & add documentation so that people can use it if they want.

I don't want to make it the default behavior for two reasons:

  • It will be backwards-incompatible for current users
  • I can imagine it would be unpredictable for some users (it's strange to pass in an underscored hash but get a camelized hash).

Thanks again, how does that sound?

@ZhangHanDong
Copy link
Contributor Author

sounds good! I'll be modify the code.

@ZhangHanDong
Copy link
Contributor Author

@rmosolgo

I have added a config option:

MyApp::Application.configure do
  config.react.camelize_props = true #default false
end

please review, thanks!

@rmosolgo
Copy link
Member

🎉 thanks, this is great!

rmosolgo pushed a commit that referenced this pull request Nov 25, 2015
Snake-Case key to Camel-Case key for props when server render
@rmosolgo rmosolgo merged commit 0a71a94 into reactjs:master Nov 25, 2015
@ZhangHanDong
Copy link
Contributor Author

@rmosolgo thanks

@yoonsy
Copy link

yoonsy commented Nov 30, 2015

👍

hfwang added a commit to porkbuns/react_webpack_rails that referenced this pull request Jan 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants