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

The warning for uncontrolled -> controlled inputs is confusing #17069

Closed
vcarl opened this issue Oct 11, 2019 · 7 comments · Fixed by #17070
Closed

The warning for uncontrolled -> controlled inputs is confusing #17069

vcarl opened this issue Oct 11, 2019 · 7 comments · Fixed by #17070

Comments

@vcarl
Copy link
Contributor

vcarl commented Oct 11, 2019

Do you want to request a feature or report a bug?

Bug? Mild DX improvement.

What is the current behavior?

Creating an input with an undefined or null value, then later passing a string value, triggers a warning about controlled inputs.

A component is changing an uncontrolled input of type undefined to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa)

It's my experience in Reactiflux that this warning is unclear to developers with less familiarity with React, or at least with the "controlled" and "uncontrolled" terms.

@bvaughn
Copy link
Contributor

bvaughn commented Oct 12, 2019

FWIW the full warning text is:

A component is changing an uncontrolled input of type %s 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

I agree that developers may be unfamiliar with the terms "controlled" and "uncontrolled" but that's why we link to the documentation explaining what those terms mean 😄

@vcarl
Copy link
Contributor Author

vcarl commented Oct 14, 2019

True, but I still think the lede of "you didn't give it a value, then you did" is pretty buried. This warning feels like it gets asked about more frequently than any other.

@markerikson
Copy link
Contributor

markerikson commented Oct 16, 2019

fwiw, I can vouch that this comes up fairly often.

I would suggest adding a sentence like "This is likely caused by value={something} changing from undefined to a defined value".

@stale
Copy link

stale bot commented Jan 14, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution.

@stale stale bot added the Resolution: Stale Automatically closed due to inactivity label Jan 14, 2020
@markerikson
Copy link
Contributor

definitely not stale - #17390 is in progress.

@stale stale bot removed the Resolution: Stale Automatically closed due to inactivity label Jan 14, 2020
@vcarl
Copy link
Contributor Author

vcarl commented Jan 14, 2020

#17070 as well

@sammy007

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants