Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use wrap-form-element for uncontrolled inputs #123

Merged
merged 1 commit into from
Jul 4, 2016
Merged

Do not use wrap-form-element for uncontrolled inputs #123

merged 1 commit into from
Jul 4, 2016

Conversation

tonsky
Copy link
Contributor

@tonsky tonsky commented Jul 4, 2016

When using uncontrolled inputs (defaultValue instead of value, defaultChecked instead of checked), wrap-form-element will eventually convert it to controlled one by setting value on it. React will issue a warning about switching between controlled and uncontrolled flavours which is considered not really supported.

This patch checks if generated input is controlled or not, and switches to wrapped form only for controlled elements.

It also

  • saves one closure allocation ((partial js/React.createElement (name type)))
  • fixes displayName
  • replaces createFactory and React.DOM (both considered legacy) with React.createElement

@r0man
Copy link
Owner

r0man commented Jul 4, 2016

@tonsky Thanks for the patch. What about the "option" tag, does it not need to be wrapped anymore?

@tonsky
Copy link
Contributor Author

tonsky commented Jul 4, 2016

I don’t think so, no. In React, you set selected value on select, not by specifying selected=true on option as in HTML. React option doesn’t have controlled/uncontrolled variety. Select does. That’s why I’ve added select to wrapped elements in my patch (it was filtered out before by wrapped-type?)

@r0man
Copy link
Owner

r0man commented Jul 4, 2016

Ok, thanks for the explanation.

@r0man r0man merged commit 70c24a9 into r0man:master Jul 4, 2016
@r0man
Copy link
Owner

r0man commented Jul 4, 2016

@tonsky Just pushed 0.7.3-SNAPSHOT to Clojars.

@tonsky
Copy link
Contributor Author

tonsky commented Jul 4, 2016

awesome!

On Tue, Jul 5, 2016 at 12:32 AM r0man notifications@github.com wrote:

@tonsky https://github.com/tonsky Just pushed 0.7.3-SNAPSHOT to Clojars.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#123 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AARabPBygWKqvLuxCzN2hTi46Gcehq0eks5qSVHEgaJpZM4JEfxk
.

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.

None yet

2 participants