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

changing an uncontrolled input of type text to be controlled #90

Closed
zeroasterisk opened this issue Aug 4, 2016 · 5 comments
Closed
Assignees
Labels
Type: Bug Bug reports and their fixes

Comments

@zeroasterisk
Copy link
Contributor

zeroasterisk commented Aug 4, 2016

Warning: Text is changing an uncontrolled input of type text to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://fb.me/react-controlled-components

Have you seen this?

I'm using this from a child component, setting state up to the parent:

parent (state.query)
  - component
    - AutoForm onSubmit={this.props.setQuery} model={this.props.query}

so on first render this.props.query = {}

then I type into a field, submit moves it into the parent's state, passes it back down via props, and it results in this.props.query = { name: 'foo' }

that seems normal to me, but react seems to be complaining...

@zeroasterisk
Copy link
Contributor Author

As expected, when I default the model with empty strings for these fields, it works fine, no complaints.

Is that a requirement?

What about non-string values, like a select number 1-10... if I don't have a value, I don't really want to default to 0since 0 is not allowed... ??

@radekmie radekmie added the Type: Bug Bug reports and their fixes label Aug 5, 2016
@radekmie radekmie self-assigned this Aug 5, 2016
@radekmie
Copy link
Contributor

radekmie commented Aug 5, 2016

This should be done by initialValue (and this small hack). Two questions:

  1. Which version?
  2. Is this field required in your schema?

@zeroasterisk
Copy link
Contributor Author

  1. v 1.0.0-rc.29
    "uniforms": "^1.0.0-rc.29",
    "uniforms-bootstrap4": "^1.0.0-rc.29",
  1. no - this is an optional field, not in the initial document/model... then type to "set" it and we get this ugly warning.

@radekmie
Copy link
Contributor

radekmie commented Aug 8, 2016

Okay, I try to investigate it but could you try it in 1.0.0-rc.28?

@radekmie
Copy link
Contributor

radekmie commented Aug 9, 2016

It was a regression in 1.0.0-rc.29 - fixed now.

@radekmie radekmie moved this to Closed in Open Source Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Bug reports and their fixes
Projects
Archived in project
Development

No branches or pull requests

2 participants